【问题标题】:Apache Rewrite CLEAN url?Apache 重写 CLEAN url?
【发布时间】:2013-01-05 21:33:12
【问题描述】:

所以我想知道是否有人愿意帮助我,或者告诉我是否有可能为我的网址做我想做的事情。

所以我希望网址是这样的

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

'()' 包围的变量需要是我可以解析的 php 变量。这是否可能/对 mod 重写的正则表达式有任何帮助。

我也可以说网址的子部分,只显示一个季节或所有季节的所有剧集。例如: http://www.example.com/(seriesname)/season/(seasonnumber) 将显示指定季节的所有剧集。

【问题讨论】:

    标签: apache mod-rewrite url-rewriting


    【解决方案1】:

    给你:

    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
    

    【讨论】:

    • 我遇到的一个问题是 RewriteRule ^/series/([^/]*)$ index.php?name=$1 当我转到 localhost/series/xxx 时不会重写
    猜你喜欢
    • 2014-05-27
    • 2010-10-30
    • 1970-01-01
    • 2011-03-17
    • 2017-05-17
    • 2018-02-20
    • 2014-05-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多