Forum Moderators: phranque
[L] flag. ^filename becomes ^folder/filename RewriteRule to make the code more readable. RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /California/index\.shtml[^ ]*\ HTTP/
RewriteRule ^California/index\.shtml http://www.example.com/California/ [R=301,L] RewriteCond %{REQUEST_URI} !/states/states_root\.cgi
RewriteRule ^California/([a-z0-9-]+)$ http://www.example.com/California/$1/ [R=301,NC,L] [a-z0-9-] rule pattern doesn't allow for any slashes or periods so it can never match "states/states_root\.cgi" anyway. RewriteRule ^California$ http://www.example.com/California/ [R=301,L] RewriteRule ^California/?$ /states/states_root.cgi?State=CA&specialty_name=$2 [L] ^California/$ here. RewriteRule ^California/(.*)$ /states/states_root.cgi?State=CA&Page=$1&specialty_name=$2 [L] /(.*)$ with /([^/]+)/([^/]+)/$ or perhaps even /([^/]+)/([^/.]+)$ if you decide to use URLs that do NOT end with a trailing slash for pages. RewriteRule California/index.shtml http://www.example.com/California/ [R=301,L]
RewriteCond %{REQUEST_URI} !/states/states_root.cgi
RewriteRule ^California/([A-Za-z0-9-]+)$ http://www.example.com/California/$1/ [R=301,L]
RewriteRule ^California$ http://www.example.com/California/ [R=301,L]
RewriteRule ^California/?$ /states/states_root.cgi?State=CA&specialty_name=$2 [L]
RewriteRule ^California/(.*)/$ /states/states_root.cgi?State=CA&Page=$1&specialty_name=$2 [L] lucy, I compared your code to mine (line by line) and couldn't find a change
For some reason your first conditional redirect causes an internal server error (RewriteCond: bad flag delimiters)
I did change the conditional as follows which seems to avert the error
The only thing I can see is an extra newline character on my last line
REQUEST_URI is updated to point to a different internal resource after an internal rewrite. THE_REQUEST contains the original GET /thisthing HTTP/1.1 THE_REQUEST to be sure that you're looking at what was requested by the browser, rather than as a result of a previous internal rewrite. example.com/index.php non-canonical URL. www.example.com/ canonical URL. /index.php internal path to fetch the content. REQUEST_URI instead of THE_REQUEST in (2) then when step (3) is executed, the reparse of the htaccess file will re-match the redirecting rule (htaccess is reparsed until no more rules match the current request), invoke it and expose the previously rewritten internal path back out on to the web as a new URL. Requesting example.com/index.php will redirect to www.example.com/ and then requesting www.example.com/ will internally rewrite to index.php and then immediately redirect to www.example.com/index.php. The browser requests www.example.com/index.php and around you go again. You've now got an infinite loop. [^ ]* should have been [^\ ]* as Lucy pointed it.