问题
So i have a mvc system setup but it does not generate search engine friendly urls.
A typical url is in the format:
http://sitedomain.com/class/classMethod?parameter=valueA?parameter2=valueB
This is what i need to have:
http://sitedomain.com/class/valueA/valueB/
My .htaccess actually modified a part of the url already but i dont know how to do the second part
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?controller=$1 [L,QSA]
(originally looked like http://site.com/index.php?controller=class
, but after the htaccess below is ran, it looks like http://site.com/class
)
If anyone could help me with this, that would be great, thank you.
回答1:
RewriteRule ^/class/(.*)/(.*)/$ index.php?controller=class¶meter=$1¶meter2=$2 [L,QSA]
回答2:
I use the following .htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ rewrite.php?%{QUERY_STRING}
And extracting parts from the url is all done in PHP.
Parsing the $_SERVER['SCRIPT_NAME']
variable.
(I find php code much easer to debug than complex apache rewrite rules.)
来源:https://stackoverflow.com/questions/3825989/htaccess-to-change-url