Allowing a . within the Rewrite Rule

Using mod_rewrite to handle various content issues

And while we are at it....

Postby anawaz » Wed Jul 29, 2009 12:02 pm

Here is another question:

RewriteRule ^([^/]+\.[^/]+)$ ./index.php?vwebsite=$1 [L]

I've got this going to get to resolve in the background to

However, now, I want all requests that go to in the browser to autmatically be 301'd to so the URL is prermanently SEO friendly.

Trying the following, but clearly I am missing something!

Code: Select all
RewriteCond %{QUERY_STRING} ^vwebsite=(.*)$
  RewriteRule ^index\.php$$1? [R=301,L]

Thanks again, Richard.
Posts: 7
Joined: Wed Jul 15, 2009 1:49 am
Location: London

Postby richardk » Wed Jul 29, 2009 4:05 pm

You need
Code: Select all

to stop loops. (It only matches new requests, not the internal mod_rewrite sub requests.)

Variables from RewriteConds are %n not $n.

If you know the vwebsite variable should match [^/]+\.[^/]+, use it.

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{QUERY_STRING} ^(.*&)?vwebsite=([^/]+\.[^/]+)(&.*)?$ [NC]
RewriteRule ^(index\.php)?$ [R=301,L]

RewriteRule ^([^/]+\.[^/]+)$ /index.php?vwebsite=$1 [L]
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Content

Who is online

Users browsing this forum: No registered users and 2 guests