Forum Moderators: phranque
Here's the old one:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}/somedir/$1/ !-d
RewriteRule ^([^/]+)/$ [somedomain.com...] [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)$ /somedir/script.cgi?cat=$1 [L]
What I want to create right now is a new htaccess file for a new dir that will help to transform the following:
[somedomain.com...]
...into...
[somedomain.com...]
So as you can see I want to pass the "Some-String-1/Some-String-2" part directly to the script as a variable. I don't want to pass "Some-String-1" as one var and "Some-String-2" as another, but instead both of them WITH the "/" as one.
HOWEVER!
It is possible that inside the link there will be only "Some-String-1" eg. [somedomain.com...] then I'd want to pass just "Some-String-1" to the script.
Please tell me it can be done - beer's on me!
BTW: the dashes in "Some-String-1/Some-String-2" - are there intentionally as I they will be present in the original version as well.
Thanks a lot!
If I go to somedomain.com/dir/String-1 FF gives some error saying "Firefox has detected that the server is redirecting the request for this address in a way that will never complete." I guess some redirect loop might be occurring?
If I type in somedomain.com/dir/String-1/ WITH a slash it simply gives a 404 "The requested URL /dir/String-1/ was not found on this server."
Now, as far as I can see the regex looks perfectly valid...
Here's exactly what I use in the htaccess file:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}/dir/$1/ !-d
RewriteRule ^([^/]+(/[^/]+)?)$ [somedomain.com...] [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+(/[^/]+)?)$ /dir/script.cgi?var=$1 [L]
[i]RewriteCond %{REQUEST_URI} !^/dir/[/i]
RewriteCond %{DOCUMENT_ROOT}/dir/$1/ !-d
RewriteRule ^([^/]+(/[^/]+)?)$ http://www.example.com/dir/$1 [R=301,L]
Jim