Gossamer Forum
Home : Products : Gossamer Links : Discussions :

mod_rewrite query

Quote Reply
mod_rewrite query
Hello,

I have following rewrite rule for the detailed pages:

RewriteEngine On
RewriteRule ^.*L([0-9]+)/?$ /Detailed/$1.html [L]
RewriteRule ^/Detailed/(.*)$ /cgi-bin/glinks3/page.cgi?g=$1.html [L]

which works fine
However, when i add following

RewriteCond %{HTTP_HOST} !^www.glinksdomain.com
RewriteRule (.*) http://www.glinksdomain.com/$1 [R=301,L]

The first one breaks. It just navigates to http://www.glinksdomain.com/Detailed/285html.html (a page not found) for example when the link is clicked from google to the said page, a link which does not have www as on google.

Can this be corrected to that i have a 301 redirect (forcing www in the url) and at the same time not breaking the static looking Detailed pages.

Thanks
HyTC
==================================
Mail Me If Contacting Privately Is That Necessary.
==================================
Quote Reply
Re: [HyperTherm] mod_rewrite query In reply to
Hre is what i did directly in httpd.conf for the glinkshost

RewriteEngine On
RewriteCond %{HTTP_HOST} ^glinks3domain\.com
RewriteRule ^(.*)$ http://www.glinks3domain.com/$1 [R=permanent,L]

RewriteRule ^.*L([0-9]+)/?$ /Detailed/$1.html [L]
RewriteRule ^/Detailed/(.*)$ /cgi-bin/glinks3/page.cgi?g=$1.html [L]

With the above in place:

http://glinks3domain.com becomes

http://www.glinks3domain.com// <--- extra / in the redirected url

http://glinksdomain.com/perl/glinks3/page.cgi?d=1 doesn't get rewritten

All Detailed/rewritten url when accessed from dynamic pages still has that extra / before detailed.

The rewritten url's of the detailed page when accessed from glinks3domain.com pages is fine and appears as:

http://www.glinks3domain.com/Detailed/rewritten-static-looking-url/

However, when a listing on google (indexed url being without www) the redirect is as follows

http://www.glinks3domain.com//Detailed/
rewritten-static-looking-url/ <-- extra / just before Detailed directory

Accessing a link from google where it is indexed with www there is no extra /

How do i get rid of the extra /


How do i get rid of the extra / as noted above in red


Thanks
HyTC
==================================
Mail Me If Contacting Privately Is That Necessary.
==================================

Last edited by:

HyperTherm: Nov 18, 2005, 11:16 PM
Quote Reply
Re: [HyperTherm] mod_rewrite query In reply to
Code:
RewriteRule ^/?(.*)$ http://www.glinks3domain.com/$1 [R=permanent,L]

Should help with the extra /. Not too sure about the other problem though :/

~Charlie
Quote Reply
Re: [Chaz] mod_rewrite query In reply to
Thanks that took care of the extra /
Still stuck with following:

http://glinksdomain.com/perl/.....

doesn't go to

http://www.glinksdomain.com/perl/....

However

http://glinksdomain.com/cgi-bin/....

goes fine to

http://www.glinksdomain.com/cgi-bin/....

Thanks 1ce again
HyTC