Rewrite question

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 ...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-08-2005
Oliver Spiesshofer
 
Posts: n/a
Default Rewrite question

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

  #2 (permalink)  
Old 03-08-2005
Oliver Spiesshofer
 
Posts: n/a
Default Re: Rewrite question

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

  #3 (permalink)  
Old 03-08-2005
Oliver Spiesshofer
 
Posts: n/a
Default Re: Rewrite question

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?

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 10:02 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0