Forum Moderators: phranque
Been reading everything I can find for several days.
Beginners guide, Tutorials, and dozens of the posts here, but still haven't got it right...
Trying to change:
This ==>http://mysite.com/Dir1/Dir2/Dir3/Var1/Var2/Var3
To This ==>http://mysite.com/Dir1/Dir2/Dir3/Var1.php?c=Var2&p=Var3
1)Mod_rewrite functional(tested with a page substitution)
2)No httpd.conf access ..so using .htaccess file in root
3)All Vars will be 'alpha'
4)Getting Not Found error using the following:
Options +FollowSymlinks
RewriteRule ^(.*)/Dir1/Dir2/Dir3/(.*)/(.*)/(.*)$ $1/Dir1/Dir2/Dir3/$2\.php?c=$3&p=$4 [L]
Thanks for any help, advice and/or direction.
Bob
Welcome to WebmasterWorld [webmasterworld.com]!
This ==>http://mysite.com/Dir1/Dir2/Dir3/Var1/Var2/Var3To This ==>http://mysite.com/Dir1/Dir2/Dir3/Var1.php?c=Var2&p=Var3
Options +FollowSymlinks
RewriteRule ^(.*)/Dir1/Dir2/Dir3/(.*)/(.*)/(.*)$ $1/Dir1/Dir2/Dir3/$2\.php?c=$3&p=$4 [L]
RewriteRule ^Dir1/Dir2/Dir3/(.*)/(.*)/(.*)$ /Dir1/Dir2/Dir3/$1\.php?c=$2&p=$3 [L]
RewriteRule ^Dir1/Dir2/Dir3/(.+)/(.+)/(.+)$ /Dir1/Dir2/Dir3/$1.php?c=$2&p=$3 [L]
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^Dir1/Dir2/Dir3/(.+)/(.+)/(.+) /Dir1/Dir2/Dir3/$1.php?c=$2&p=$3 [L]
Jim
My thanks to Storyteller and jdMorgan for the help and clarifying instructions.......
Now getting correct page/s, but lost all my images and the style sheets......
Seems to be looking for them in the next directory below the called page (unfortunetly they're in directories on the same level as the called page).....
Tried an exclusion just before the RewriteRule as follows:
RewriteCond %{REQUEST_URI}!\.(css¦js¦jpe?g¦gif¦swf)$
No go....same result...get the page with no styling/images.
Realize I can move the stylesheets and images....but
is there possibly another avenue to expore?
Thanks again.
Bob
Take a look at your error log and find out where the server is looking for these missing image/js/css files both with and without the exclusion Cond; adding that exclusion should have changed things if the image/js/css requests were matching (and invoking) the RewriteRule.
With that knowledge, you should be able to compose a rule to rewrite the image/js/css URLs before testing/rewriting the script calls. Terminate the image/js/css rewrites with an [L] flag so the URL does not get rewritten twice.
RewriteCond %{REQUEST_URI} \.(css¦js¦jpe?g¦gif¦swf)$
RewriteRule <some pattern and substitution for images/js/css> [L]
RewriteRule ^(.*)/Dir1/Dir2/Dir3/(.*)/(.*)/(.*)$ $1/Dir1/Dir2/Dir3/$2\.php?c=$3&p=$4 [L]
If you're still having trouble, please post a before & after (actual & rewritten) URL for an image file as an example - I can't work out how you are calling images and how they might fit into (match) your existing RewriteRule. (Change the domain name to comply with WebmasterWorld TOS)
Jim
The info in the access log did not change whether the - RewriteCond %{REQUEST_URI}!\.(css¦js¦jpe?g¦gif¦swf)$
was included or not....the access log showed server looking
in same place.
Server is trying to access images at:
[mysite.com...]
They are actually located at:
[mysite.com...]
I tried the following:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^Dir1/Dir2/Dir3/(.+)/images/(.+)\.(css¦js¦jpe?g¦gif¦swf)$ /Dir1/Dir2/images/$2.(css¦js¦jpe?g¦gif¦swf) [L]
RewriteRule ^Dir1/Dir2/Dir3/(.+)/(.+)/(.+)$ /Dir1/Dir2/Dir3/$1.php?c=$2&p=$3 [L]
Get the page but not the images.
Thanks again for any further direction.
Bob
You can only use an alternation in a pattern, not in a substitution, so try this:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^Dir1/Dir2/Dir3/(.+)/images/(.+)\.(css¦js¦jpe?g¦gif¦swf)$ /Dir1/Dir2/images/$2.$3 [L]
RewriteRule ^Dir1/Dir2/Dir3/(.+)/(.+)/(.+)$ /Dir1/Dir2/Dir3/$1.php?c=$2&p=$3 [L]
Jim