我的网站如下:
| _index.php
|?_index.php页=约
| _articles {DIR}
|?_articles / index.php页面= 2
|?_articles / article_detail.php ID = 1个
| _events {DIR}
|?_events / event_detail.php EVENT_ID = 1
如何让htaccess使用
这样的网址 mysite.com/about
mysite.com/articles/page/1/
mysite.com/articles/1/
mysite.com/events/1/
答案 0 :(得分:1)
尝试
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ /index.php?page=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^articles/([^/]+)/?$ /articles/article_detail.php?id=$1 [L]
RewriteRule ^articles/page/([^/]+)/?$ /articles/index.php?page=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^events/([^/]+)/?$ /events/event_detail.php?id=$1 [L]