-1

Possible Duplicate:
mod_rewrite, php and the .htaccess file

Would like this to happen in the .htaccess file. to rewrite

index.php?pagetype=name

to

/pagetype/name/

do this for all pagetypes so

?user=name
?post=number
?life=sucks ... etc

but would like to exclude

/css/
/images/
/js/
/php/
/template/

so the variable links still work.

I am guessing this should work but I want it in it's most simplest form so I don't have to change the .htaccess file everytime I add a pagetype.

I did a search for this but didn't find anything helpful.

The site will only have one physically accessed file: index.php then the rest are processed via $_GET commands

Community
  • 1
  • 1
  • No, you want to rewrite the (incoming SEO/SEF format URI) `/pagetype/name/` to `/index.php?pagetype=name` (which your PHP code can digest). Please get the terminology right! – Phil Perry Dec 06 '13 at 17:57

1 Answers1

1

Just for the example you specified, the simplest approach would be:

 RewriteCond  %{REQUEST_URI}   !^/(css|images|js|php|template)/
 RewriteRule  ^(\w+)/(\w+)/?$  index.php?$1=$2  [QSA,L]

(The RewriteCond could be written as negative lookeahead in the Rule instead of course.)

See also the mod-rewrite tag wiki for further howtos.

Community
  • 1
  • 1
mario
  • 144,265
  • 20
  • 237
  • 291