regex - Mod Rewrite php htacess -


i'm trying use clean urls on website better seo. i'm doing doing using mod rewrite htaccess. url follows http://mywebsite.com/s.php?share=100 , accept urls http://mywebsite.com/s/100 or whatever number user chooses. i'm using rewrite regex expression not working expected

   rewriteengine on    rewritecond %{request_filename}!-f    rewritecond %{request_filename}!-d    rewriterule ^([a-z]+)/([a-z\-]+)$ /$1/$2.php     rewriterule ^share/([^/]*)$ /s.php?share=$1 [l] 

can point me i'm doing wrong?

you want url http://mywebsite.com/s/100, meaning uri /s/100, pattern looks ^share/([^/]*)$. since uri doesn't begin "share", pattern never match uri want. try:

rewriterule ^s/([^/]*)$ /s.php?share=$1 [l] 

also, since requesting /s/ , have file called /s.php, need make sure multiviews turned off:

options -multiviews 

so altogether, like:

options -multiviews  rewriteengine on rewritecond %{request_filename}!-f rewritecond %{request_filename}!-d rewriterule ^([a-z]+)/([a-z\-]+)$ /$1/$2.php  rewriterule ^s/([^/]*)$ /s.php?share=$1 [l] 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -