Relocated Some Content to Sub Dir and Need Help

Using mod_rewrite to handle various content issues

Relocated Some Content to Sub Dir and Need Help

Postby smashingred » Mon Mar 26, 2007 10:19 am

Hey folks, first post,

I have searched the forums for a solution for the following problem:

I relocated the contents of my webroot to a subdirectory and have placed another CMS that uses its own URL structure.

I want all document requests with the following:
Code: Select all
index.php?action=

To be redirected to the same document but in the subdirectory.
The real urls contain a query string like the following URL:
Code: Select all
http://www.example.com/index.php?action=listingview&listingID=23

The result I seek is the following:
Code: Select all
http://www.example.com/listings/index.php?action=listingview&listingID=23

I have tried various and sundry versions of the following to redirect it with no success:
Code: Select all
Options +FollowSymLinks

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php\?action=(.*)$ subdir/index.php?action=$1 [R=301,L]



I can't use a rule to rewrite every url in the webroot as it will screw up friendly urls in the new content of the root.

Thanks in advance for the help.
smashingred
 
Posts: 2
Joined: Mon Mar 26, 2007 9:53 am
Location: Bridgewater, NS Canada

Postby richardk » Mon Mar 26, 2007 1:10 pm

You need QUERY_STRING
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{QUERY_STRING} ^(.*&)?action= [NC]
RewriteRule ^(index\.php)?$ /subdir/index.php [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby smashingred » Mon Mar 26, 2007 1:22 pm

WOW! Thanks. Works Perfectly.

All the best,

Jay
smashingred
 
Posts: 2
Joined: Mon Mar 26, 2007 9:53 am
Location: Bridgewater, NS Canada


Return to Content

Who is online

Users browsing this forum: No registered users and 3 guests

cron