Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mod rewrite

Status
Not open for further replies.

MrBelfry

IS-IT--Management
Joined
May 21, 2003
Messages
289
Hello

I have a mod_rewrite problem. I'm trying to rewrite a url that looks like this: to rewrite to pages.php?section=about&pagename=index

I've had this working on my windows box at work (but I put the rewrite rules in the conf file) but on my linux host (using a htaccess file in the 'new' folder I cannot get it to work. Help!

Here are my rules

Code:
RewriteEngine on

#catch index page
RewriteRule ^$ pages.php?section=home&pagename=index [L,NS,QSA]
RewriteRule ^\index.html$ pages.php?section=home&pagename=index [L,NS,QSA]

#if we try to access an html file then we rewrite otherwise we ignore
RewriteRule ^/([^/]*)/$ pages.php?section=$1&pagename=index [L,NS,QSA]
RewriteRule ^/([^/]*)/([^/]*).html$ pages.php?section=$1&pagename=$2 [L,NS,QSA]

NB. I can rewrite the homepage no problem i.e works fine.

MrBelfry
 
Might be a stupid question but : Is your linux box configured to pay attention to the .htaccess file?

if so, turn on RewriteLog and send us the output of a request. Crank the log level up to 9.



 
I tried the rewritelog it spat out an error and according to the manual RewriteLog can't be put in an htaccess file!

The following rewrite rules work
Code:
#catch index page
RewriteRule ^$ pages.php?section=home&pagename=index [L,NS,QSA]
RewriteRule ^\index.html$ pages.php?section=home&pagename=index [L,NS,QSA]

This leads me to think that the the other rules aren't being matched but I can't think why.

MrBelfry
 
For anyone who cares here is how i solved this

This:
Code:
#if we try to access an html file then we rewrite otherwise we ignore
RewriteRule ^/([^/]*)/$ pages.php?section=$1&pagename=index [L,NS,QSA]
RewriteRule ^/([^/]*)/([^/]*).html$ pages.php?section=$1&pagename=$2 [L,NS,QSA]

became this:
Code:
RewriteRule ^([^/]*)/$ pages.php?section=$1&pagename=index
RewriteRule ^([^/]*)/([^/]*).html$ pages.php?section=$1&pagename=$2

it appears that the / was the problem and I wasn't matching the rule.

MrBelfry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top