我的文件夹结构:
--root
-----includes
-----content.php
-----index.php
-----sitemap.php
-----rss.php我希望使用.htaccess文件来路由我的web应用程序,如下所示:
http://mysite.domain/ => index.php
http://mysite.domain/any-slug/ => content.php
http://mysite.domain/sitemap.xml => sitemap.php
http://mysite.domain/any-slug.rss => rss.php这是我的.htaccess文件:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^sitemap.xml$ sitemap.php
RewriteRule ^(.+).rss$ rss.php?slug=$1
RewriteRule ^(.+)$ content.php?slug=$1 [QSA,L]但是,它不起作用。有人能帮帮我吗?
发布于 2015-07-14 22:31:23
我不知道您是否解决了这个问题,但是.htaccess文件只是将所有请求重新路由到index.php。从那里,您需要使用路由器,以便根据提交的url显示不同的页面。
例如:
home索引用户访问localhost/home/index/hello.
https://stackoverflow.com/questions/29447658
复制相似问题