Apache Rewrite CLEAN url?

北慕城南 提交于 2019-12-11 02:29:54

问题


So I'm wondering if anyone would be willing to help me, or tell me if it's possible to do what I'm thinking of for my urls.

So I want the urls to be like so

http://www.example.com/(seriesname)/season/(seasonnumber)/episode/(episodenumber)

The variables surrounded by '()' will need to be php variables that I can parse. Is this possible/any help on the regex for mod rewrite.

And I could also go to lets say sub parts of the url to just show all episodes in a season or all seasons. EG: http://www.example.com/(seriesname)/season/(seasonnumber) will display all episodes in specified season.


回答1:


here you go:

RewriteCond %{REQUEST_URI} !=/
RewriteCond %{REQUEST_URI} !robots.txt
RewriteCond %{REQUEST_URI} !.php$
RewriteRule ^([^/]*)$ index.php?name=$1
RewriteRule ^([^/]*)/season/([^/]*)$ index.php?name=$1&season=$2
RewriteRule ^([^/]*)/season/([^/]*)/episode/([^/]*)$ index.php?name=$1&season=$2&episode=$3


来源:https://stackoverflow.com/questions/14176618/apache-rewrite-clean-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!