Php htaccess中的多个重写规则
我无法让我的url重写工作。我必须去根,这很好用。但我正在尝试添加另一条路线,但它不起作用 我想要的是:Php htaccess中的多个重写规则,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,我无法让我的url重写工作。我必须去根,这很好用。但我正在尝试添加另一条路线,但它不起作用 我想要的是: mydoma.in/ 哪些路由到index.php 然后 mydoma.in/comments 哪些路由到page-with-comments.php 这是我到目前为止的代码: # http://httpd.apache.org/docs/current/mod/core.html#errordocument #ErrorDocument 404 /404.php ErrorDocume
mydoma.in/
哪些路由到index.php
然后
mydoma.in/comments
哪些路由到page-with-comments.php
这是我到目前为止的代码:
# http://httpd.apache.org/docs/current/mod/core.html#errordocument
#ErrorDocument 404 /404.php
ErrorDocument 404 "Message"
RewriteEngine on
RewriteRule ^comment/(.*)$ page-with-comments.php/$1 [L]
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /path/needed/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php/$1 [NC,L]
</IfModule>
#http://httpd.apache.org/docs/current/mod/core.html#errordocument
#ErrorDocument 404/404.php
错误文档404“消息”
重新启动发动机
重写规则^comment/(.*)带注释的$page.php/$1[L]
选项+FollowSymLinks
重新启动发动机
重写基础/路径/需要/
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则(.*)index.php/$1[NC,L]
这两条路线也都有参数。您的
重写库似乎有故障
在root.htaccess中使用如下代码:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^comment/(.*)$ page-with-comments.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.+) index.php/$1 [L]
</IfModule>
选项+FollowSymLinks
重新启动发动机
重写基/
重写规则^comment/(.*)带注释的$page.php/$1[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则(+)index.php/$1[L]
现在有什么问题吗?抱歉,更新了内容。添加第二条路线无效。您在链接中使用了注释,在重写规则中使用了注释(复数/单数)。这只是一个输入错误吗?您启用了两次RewriteEngine
,然后您有了一个RewriteBase/path/needed/
,您正试图将/path/needed/comment/
重写为/path/needed/index.php
和/path/needed/
重写为/path/needed/index.php
。删除RewriteBase
并将RewriteRule^comment/(.*)$页面与comments.php/$1[L]
移动到块
内。