【发布时间】:2014-05-19 01:33:32
【问题描述】:
我在名为“pages”的文件夹中有一个名为 about.php 的页面。
我已成功从 url 中删除了 .php 和目录,但现在页面打不开。
我所有的文件都在 localhost/test/ 文件夹中。 所以过去一切都以 localhost/test/pages/about.php 的形式正常打开 现在它显示 localhost/test/about 并且没有打开。
RewriteBase /test/
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.php($|\ |\?)
RewriteRule ^ /%1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
RewriteRule ^pages/(.*)$ $1 [L,NC,R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^/]+)/?$ $1.php [L]
【问题讨论】:
-
你能澄清一下你真正想要达到的目标吗?您正在尝试将请求重定向到
mysite.com/about到内部文件/test/about.php? -
是的。 localhost/test/about 内部重定向到 localhost/test/pages/about.php。我似乎在 url 中工作,但页面没有加载
标签: php regex apache .htaccess mod-rewrite