所以我有一个MVC系统设置,但它不会生成搜索引擎友好的URL。
So i have a mvc system setup but it does not generate search engine friendly urls.
一个典型的URL的格式为:
A typical url is in the format:
http://sitedomain.com/class/classMethod?parameter=valueA?parameter2=valueB
这是我需要有:
http://sitedomain.com/class/valueA/valueB/
我的.htaccess真正被修改的URL中的一部分了,但是我不知道该怎么做的第二部分
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]
(最初看上去像是 http://site.com/index.php?controller=class
,但htaccess的后下方是跑,它看起来像 http://site.com/class
)
(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.
我用下面的.htaccess:
I use the following .htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ rewrite.php?%{QUERY_STRING}
和从URL中提取的部分是在PHP中全部完成。
解析 $ _ SERVER ['SCRIPT_NAME']
变量。
And extracting parts from the url is all done in PHP.
Parsing the $_SERVER['SCRIPT_NAME']
variable.
(我发现PHP的code多少easer比复杂的阿帕奇重写规则进行调试。)
(I find php code much easer to debug than complex apache rewrite rules.)