htaccess RewriteRule Issues
I have a PHP page reading $_GET variables in as category and page.
I then have the .htaccess forwarding url.com/categroy/page to the index.php file for it to do the work.
I cannot however get the htaccess rules working
RewriteEngine On
RewriteRule ^/([^/]+)/(.[^/]) /index.php?开发者_JAVA百科category=$1&page=$2
RewriteRule ^/([^/]) /index.php?page=$1
Any ideas as to what i am missing?
Your rules lack the endling delimiter $
. And the .
is misplaced at that position. Also you need a +
quantifier for the second []
character class:
RewriteRule ^([^/]+)/([^/]+)$ index.php?category=$1&page=$2 [L]
RewriteRule ^([^/]+)$ index.php?page=$1 [L]
I'm not sure about this, but I also removed the leading /
slash. It should be implicit when you place your .htaccess in the root folder.
Additionally you probably will need the typical RewriteCond to exclude any real filenames from getting rewritten. Place this before each RewriteRule:
RewriteCond %{REQUEST_FILENAME} !-f
精彩评论