Forum Moderators: phranque
This part is working fine.
I can also use variables like page.php?var=1 as /page/var/1/
My problem is when I submit a form, the form will go to page.php?var=1
Now I think I need to redirect it to /page/var/1/ but when I do this, it is reading page.php?var=1 as it told leading the script back to square 1 resulting in a continuous never ending loop.
Is there a way around this?
Any help is appreciated,
Michael
I've got a system which in theory should work, but sadly in reality it doesn't.
When a form is submitted it will be submitted using the get method the url will be as so: page/?var=1
I want it to change to /page/var/1/
Here is my code:
RewriteRule ^(.*)/\?(.*)=(.*)$ /$1/$2/$3/ [R=301]
RewriteRule ^(.*)/$ /hg/$1.php
RewriteRule ^(.*)/(.*)/(.*)$ /$1.php?$2=$3
If you use a redirect, then the problem is that "it's too late," since the original URL has already been "published" on the page.
The normal procedure is:
Your code may have been intended to do this. If it was, there are numerous problems with it, and all I can suggest is a re-write of the code:
# Redirect direct client requests (only) for dynamic URL to static URL
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /[^.]+\.php\?([^&=]+)=([^&\ ]+)\ HTTP/
RewriteRule ^([^.]+)\.php$ http://www.example.com/$1/%1/%2/ [R=301,L]
#
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ /$1.php?$2=$3 [L]
RewriteRule ^([^/]+)/?$ /hg/$1.php [L]
More-detailed info in this thread: Changing Dynamic URLs to Static URLs [webmasterworld.com]
Jim