Solved

Mod Rewrite Not Working

Posted on 2011-03-06
4
307 Views
Last Modified: 2012-05-11
Hello All--
What I am trying to do is redirect URLs formatted like this:
xyz.com/blog/?p=918
to this
xyz.com/?p=918

So I want to preserve the query string at the end, but ditch the subdirectories with 301s.  

Attached is what a previous expert gave me.  Obviously, I changed the domain name to my own.  I uploaded the file to public_html and no go... The redirect isn't happening.  Any ideas?


RewriteEngine on

RewriteRule ^http://domain.org/blog/(.*)$  http://domain.org/$1 [R=301,L]

Open in new window

0
Comment
Question by:nplescher
  • 2
  • 2
4 Comments
 
LVL 16

Expert Comment

by:sjklein42
ID: 35045366
Try it without the domain:

RewriteEngine on

RewriteRule ^blog/(.*)$  $1 [R=301,L]

Open in new window

0
 

Author Comment

by:nplescher
ID: 35045751
No.

Using this rewrite redirects the user to:

http://domain.org/home/username/public_html/?p=980
0
 
LVL 16

Accepted Solution

by:
sjklein42 earned 500 total points
ID: 35045772
Maybe you're missing the RewriteBase line:

Options +FollowSymLinks
 
RewriteEngine On
RewriteBase /

RewriteRule ^blog/(.*)$  $1 [R=301,L] 

Open in new window

0
 

Author Closing Comment

by:nplescher
ID: 35047036
Perfect!!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now