我的网址是:
www.page.com/events
www.page.com/events-item?event=title-event
我想网址看起来像这样:
www.page.com/events - this is list of events
www.page.com/events/item/title-event - this is event
我的.htacces:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteRule ^events/item/(.*)$ /events-item.php?event=$1
Xampp改变:
http://www.leonardaustin.com/blog/technical/enable-mod_rewrite-in-xampp/
我不知道为什么不起作用。
帮助任何人?
答案 0 :(得分:1)
更改规则的顺序。把你的所有规则放在最后,而不是在开头。
RewriteEngine On
// Rewrite this before the catch-all
RewriteRule ^events/item/(.*)$ /events-item.php?event=$1 [L]
// Catch-all rule for non-files, non-directories
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
结果:
http://www.page.com/jakis-title - > http://www.page.com/jakis-title.php
http://www.page.com/jakis-title.php - > http://www.page.com/jakis-title.php
http://www.page.com/events/item/title-event - > http://www.page.com/events-item.php?event=title-event
答案 1 :(得分:0)
我纠正了
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteRule ^event/item/(.*)$ /events-item.php?event=$1 [L]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
网址工作!但...
/事件/项目/ jakis标题
当我的$ _get ['url'] ='jakis-title.php'时,此网址正常工作
删除'.php'时不起作用
我想变量没有扩展名