Small change to rewrite rules...

Discuss practical ways rearrange URLs using mod_rewrite.

Small change to rewrite rules...

Postby renefournier » Mon Jul 21, 2008 6:33 am

I'm transferring a web site to a new host, but it will be one level deeper from the document root. Currently, a typical URL looks like:

http://www.before.com/en/home/

But after the move it will be:

http://www.after.com/www/en/home/

(Notice the additional "www".)

I need to edit the following so as to accommodate the prefix "www", but I'm not sure how... Any ideas?


----
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^trace$ [NC]
RewriteRule .* - [F]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^((en|de|ru)/[a-z0-9-_]+)\.php$ /$1/ [NC,R=301,L]
RewriteRule ^((en|de|ru)/[a-z0-9-_]+)$ /$1/ [NC,R=301,L]
RewriteRule ^(en|de|ru)/([a-z0-9-_]+)/$ /index.php?lang=$1&page=$2 [NC,QSA,L]
----


...Rene

Thanks.
renefournier
 
Posts: 9
Joined: Mon Jun 11, 2007 8:21 pm

Postby richardk » Tue Jul 22, 2008 10:36 am

Try this, in /www
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{REQUEST_METHOD} ^trace$ [NC]
RewriteRule .* - [F]

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^((en|de|ru)/[-a-z0-9_]+)\.php$ /www/$1/ [NC,R=301,L]

RewriteRule ^((en|de|ru)/[-a-z0-9_]+)$ /www/$1/ [NC,R=301,L]

RewriteRule ^(en|de|ru)/([-a-z0-9_]+)/$ /www/index.php?lang=$1&page=$2 [NC,QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 101 guests

cron