i am looking for some help ---
we hope to "lose" the question mark in our url links---
the actual link - and others similar:
http://www.webshop101.com/alohaShop/?page=shop/reminders
i have tried to use:
RewriteEngine on
RewriteBase /
RewriteRule ^page([0-9]*).php /index.php?page=
we have mod_rewrite enbled on server -
see: http://www.webshop101.com/alohaShop/about/
using:
RewriteEngine on
RewriteRule ^(.+)$ [tropicalflowerworld.com...]
any suggestions would be much appreciated
(edited by: engine at 5:17 pm (utc) on April 24, 2002)
RewriteEngine on
RewriteRule ^/icons/(.*)\.jpg$ /home/english/get_icon?v_numer=$1 [PT,L]
RewriteRule ^/pictures/(.*)\.jpg$ /home/english/get_mynd?v_numer=$1 [PT,L]
when the browser asks for /images/123.jpg it is sent to the script as /home/english/get_mynd?v_numer=123
No one is the wiser that the image was fed by a database.
And for scripts that require multiple values.
RewriteRule ^/english/pedigree/([^/]+)/printer/([^/]+)\.html$ /home/english/pedigree.printerfriendly?hund=$2&maxdepth=$1 [PT,L]
so an URL pointing to /english/pedigree/6/printer/123.html
will be served to the script as /home/english/pedigree.printerfriendly?hund=123&maxdepth=6
Hope it helps,
here is an link to an old quide to mod_rewrite (I found it really helpfull to start of reading that guide, and when later on I got more proficient, read the current one which is exponentially larger and more complex :) )
[wwwslap.cern.ch...]
Olaf
I thought it would be a great idea to create a temporary rewrite base to redirect 301 all the original urls (since they are being referenced to by many homepages and search databases)
I tried to get it to work but no luck.
for straight conversions, no problem.
but for a cgi based page i just couldnt make it happen.
this is one example that I was trying to accomplish.
(this is what I tried, have tried variations, but none worked)
RewriteRule ^/english/frodleikuri\.gsd\?num=(.*)$ /english/structure_information/$1.html [R=301]
so that any incoming urls to /english/frodleikur.gsd?num=2 would get a Redirect (301) to /english/structure_information/2.html
Anyone knows the correct syntax for this operation?
Regards
Olaf
Alternatively, you could try doing the same thing with the simpler RedirectMatch directive - less options, less chance of something going wrong ;)
RedirectMatch 301 ^/english/frodleikuri\.gsd\?num=(.*)$ /english/structure_information/$1.html
Let us know how you get on, or if you've already solved it!
One wierd thing I am encountering is that with this setup:
RewriteRule ^/english/frodleikur\.gsd$ /english/structure_information.html [R=301]
RedirectMatch 301 ^/english/frodleikur\.gsd\?num=(.*)$ /english/structure_information/$1.html
This:
..../frodleikur.gsd?num=2
Gets a 301 to this:
..../structure_information.html?num=2
Even though the RewriteRule says ^/english/frodleikur\.gsd$ <- (notice $ stop)
And if I comment out the rewriterule it does not happen.
Olaf
That's the problem. The query string. It is not matched against, rather, it is stripped off and put in the environment.
So:
RewriteRule ^/english/frodleikuri\.gsd\?num=(.*)$ /english/structure_information/$1.html [R=301]
will never match because ?num= is not even being looked at.
Semi-Solution:
rewriteCond %{QUERY_STRING} ^num=(.*)
RewriteRule ^/english/frodleikuri\.gsd$ /english/structure_information/%1.html
Note the difference %1 - are matches in the preceding RewriteCond
Now your second problem is the redirect. Since the query string is saved in the environment, if you add the redirect, the server is going to add the original query string to the Location: header along with the newly rewritten URL, and it will show up in your browser. If you don't redirect, the .gsd?num= will show up in your browser, although the .html page will be served up. I haven't checked it but maybe it would be possible to use a setenvif statement to clear the QUERY_STRING environment variable.
Also, the reason the RedirectMatch doesn't work after the RewriteRule above is because the URL has already been rewritten. It looks like the RedirectMatch is what you're wanting anyway?