.htaccess tutorial

htaccess Elite


Very simple RewriteRule question

Ask your mod_rewrite and Redirection questions here, and get answers!

Very simple RewriteRule question

New postby ElectricStudio » 08 Aug 2008 17:05

I am new to HTAccess. How do I modify this rule:

Code: Select all
RewriteRule ^(.*)$ index.php?path=$1 [QSA,NS,L]


So that it only works when '.html' isn't in the path? I think in need [^html] somewhere in there?
ElectricStudio
 
Posts: 3
Joined: 08 Aug 2008 17:00

Re: Very simple RewriteRule question

New postby Suiker » 11 Aug 2008 04:17

RewriteRule ^([^\.]+)\.html$ index.php?path=$1 [NS,L,QSA]
Suiker
 
Posts: 6
Joined: 02 Aug 2008 16:09

Re: Very simple RewriteRule question

New postby ElectricStudio » 14 Aug 2008 09:28

Thanks for your reply Suiker but I think it's incorrect?

What happens with your rule: (both incorrect)
domain.com/test.html --> domain.com/index.php?path=test
domain.com/test --> (Page not found)

What should happen:
domain.com/test.html --> domain.com/test.html (no change)
domain.com/test --> domain.com/index.php?path=test
ElectricStudio
 
Posts: 3
Joined: 08 Aug 2008 17:00

Re: Very simple RewriteRule question

New postby ElectricStudio » 14 Aug 2008 13:25

I think i've found it;

Code: Select all
RewriteCond %{QUERY_STRING} !html&?
RewriteRule ^(.*)$ index.php?path=$1 [QSA,NS,L]
ElectricStudio
 
Posts: 3
Joined: 08 Aug 2008 17:00


Return to Redirect or Rewrite Questions