微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

所有子目录使用root index.php文件

我现有的.htaccess文件如下所示:

Options -Indexes RewriteEngine On RewriteBase / RewriteRule ^(.+/)?posts/(.*)/(.*).html$ index.PHP?content=blog&postid=$2&kwd=$3 RewriteRule ^(.+/)?aposts/(.*)/(.*).html$ index.PHP?content=autopost&postid=$2&kwd=$3 RewriteRule ^(.+/)?category/(.*)/(.*).html$ index.PHP?content=category&cat=$2&otext=$3 RewriteRule ^(.+/)?content/(.*).html$ index.PHP?content=$2 RewriteRule ^(.+/)?searching/(.*).html$ index.PHP?content=search&k=$2 RewriteRule ^(.+/)?related/(.*).html$ index.PHP?content=related&k=$2 RewriteRule ^(.+/)?blog/(.*)/(.*).html$ index.PHP?content=blog&postid=$2&kwd=$3 RewriteRule ^(.+/)?posts$ index.PHP?content=blog RewriteRule ^(.+/)?sitemap.xml$ sitemap.PHP [L] RewriteRule ^(.+/)?robots.txt$ robots.PHP [L] ErrorDocument 404 /404.PHP

我想增加所有子目录使用根index.PHP文件的能力。 例如,如果访问者进入根目录:

example.com

他们得到了根index.PHP文件

我想这样如果有人去任何其他子目录,例如:

查询string参数重写到URL Apache中

Apache RewriteMap用于防止直接访问文件

为什么redirect不断改变地址栏

删除index.PHP url重写.htaccess

将htaccess转换为Nginx重写

example.com/sub1 example.com/sub1/sub2/sub3/etc..

他们得到从根目录index.PHP文件,但浏览器地址栏仍然显示子目录,例如:

example.com/sub1 example.com/sub1/sub2/sub3/etc..

显示如何添加这个规则的例外也会很好。

谢谢你的帮助。

OpenShift并在.htaccess中redirect

.htaccess,命令允许,拒绝,全部否认:困惑?

三.htaccess到期规则的区别

如何在使用Apache重写时隐藏URL更改?

意外的行为与自定义.htaccess重写规则

正确的下RewriteBase /添加

RewriteCond %{REQUEST_FILENAME} -d RewriteCond $1 !^index.PHP RewriteRule ^(.+)$ /index.PHP [L]

添加例外,只需添加更多的RewriteCond行。 例如,为了让它/foo/不被路由到index.PHP添加

RewriteCond %{REQUEST_FILENAME} -d RewriteCond $1 !^foo/ RewriteCond $1 !^index.PHP RewriteRule ^(.+)$ /index.PHP [L]

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐