Web Hosting Talk







View Full Version : Mod_rewrite redirect help


Jinovich
08-07-2008, 02:52 PM
Basically, I have moved my web application from

/public_html/news/ to /public_html/

I would like to set the redirects so that

/news/index.php?catid=22&newsid=23 would go to /index.php?catid=22&newsid=23

Basically all I want it to do is get the url and remove the /news from it so that all the links to content on my site still works.


Can anyone help as I am failing with the code for this task.


RewriteRule ^news/([^/\.]+)/?$ /$1 [L] would this rule work?

koolcards
08-07-2008, 03:24 PM
You can try this:

RewriteEngine on
RewriteRule ^/news/$ / [R]
http://httpd.apache.org/docs/1.3/misc/rewriteguide.html

Personally, I would simply replace the '/news' directory with a static link to '/public_html' :eek:

qbert220
08-07-2008, 04:33 PM
RewriteRule ^news/([^/\.]+)/?$ /$1 [L] would this rule work?

The "\." will match a dot in the "index.php" part of the URL. The match then fails.

I think

RewriteRule ^news/(.*)$ /$1 [L]

should work for you.