This is a discussion on Rewrite question within the Apache Web Server forums, part of the Web Server and Related Forums category; Hi I am having trouble with my rewrite settings. I did not do the initial setup, so I am not ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi
I am having trouble with my rewrite settings. I did not do the initial setup, so I am not sure if this is the proper way to do all what I want. What I want it to do is: 1. redirect http://kanji.server.com to http://server.com/main/staticpages/index.php/kanji/ 2. redirect /stats/ to /cgi-bin/awstats/awstats.pl 3. redirect /main/staticpages/index.php?page=whatever into /main/staticpages/index.php/whatever The settings I have do everything just fine except point number 3. I have no idea why. Are there any unnecessary settings I have? Anything conflicting? I know there is a setting that translates subdomains into subdirectories in the end, and as long this does not disturb the other settings, I dont care about it... so what is wrong? How can I get point 3 to work?? this is my rewrite setting: # -------- RewriteEngine on RewriteRule ^(.*/[^/.]+)$ http://%{HTTP_HOST}$1/ [R,L] RewriteRule ^/main/staticpages/index\.php\?page\=(.*)$ /main/staticpages/index.php/$1 [R=301,L] RewriteRule ^/stats/?$ /cgi-bin/awstats/awstats.pl [L,R] RewriteCond %{HTTP_HOST} ^kanji.server.com$ [NC] RewriteRule ^(.+) %{HTTP_HOST}$1 [C] RewriteRule ^kanji.server.com http://server.com/main/staticpages/index.php/kanji/ [R=301,L] RewriteCond %{HTTP_HOST} !^www.server.com$ [NC] RewriteCond %{HTTP_HOST} !^kanji.server.com$ [NC] RewriteCond %{HTTP_HOST} ^[^.]+.server.com$ [NC] RewriteRule ^(.+) %{HTTP_HOST}$1 [C] RewriteRule ^([^.]+).server.com(.*) /$1/$2 # ----- thanks Oliver |
|
|||
|
Oliver Spiesshofer <oliver@email.com> wrote in
news:Xns961383A857099oliveremailcom@63.223.5.254: > 3. redirect /main/staticpages/index.php?page=whatever > into /main/staticpages/index.php/whatever > > RewriteRule ^/main/staticpages/index\.php\?page\=(.*)$ > /main/staticpages/index.php/$1 [R=301,L] Actually I now found out I have t owork with the query string in this case. However, I could not fin dout how to use only the value of the page in the result of the rewrite RewriteCond %{QUERY_STRING} ^page=(.*)$ [NC] RewriteRule ^(.*)$ /$1 [R=301,L] This does not work... what is the correct way? How do I return the value behind the = into the result? thanks Oliver |
|
|||
|
Oliver Spiesshofer <oliver@email.com> wrote in
news:Xns961390CA69DB0oliveremailcom@63.223.5.246: >> 3. redirect /main/staticpages/index.php?page=whatever >> into /main/staticpages/index.php/whatever >> >> RewriteRule ^/main/staticpages/index\.php\?page\=(.*)$ >> /main/staticpages/index.php/$1 [R=301,L] > > Actually I now found out I have t owork with the query string in this > case. However, I could not fin dout how to use only the value of the > page in the result of the rewrite > > RewriteCond %{QUERY_STRING} ^page=(.*)$ [NC] > RewriteRule ^(.*)$ /$1 [R=301,L] 3rd attempt: I am getting further there, but there is one last glitch: I am using now RewriteCond %{QUERY_STRING} ^(.*)?page=(chart2)$ which works with RewriteRule ^(.*)? $1?%1%2%3 [R=301,L] but gives http://server.com/main/staticpages/index.php?chart2 to get http://server.com/main/staticpages/index.php/chart2, I tried RewriteRule ^(.*)? $1/%1%2%3 [R=301,L] but this wont work at all. the browser gets stuck any idea? |