【发布时间】:2011-11-18 02:15:16
【问题描述】:
我想要以下:
-
www.bla-bla.com/-->www.bla-bla.com/php/index.php -
www.bla-bla.com/php/index.php-->www.bla-bla.com/php/error.php
我尝试了以下方法但不起作用
RewriteEngine on
RewriteRule ^/?$ /php/index.php [S=1]
RewriteCond %{REQUEST_URI} =/php/index\.php
RewriteRule (.*)? /php/error.php [R=404]
如何拒绝来自真实路径的访问?
URL=http://localhost
(3) [perdir C:/xampp/htdocs/] strip per-dir prefix: C:/xampp/htdocs/ ->
(3) [perdir C:/xampp/htdocs/] applying pattern '/php/index\.php' to uri ''
(3) [perdir C:/xampp/htdocs/] strip per-dir prefix: C:/xampp/htdocs/ ->
(3) [perdir C:/xampp/htdocs/] applying pattern '^(/?)$' to uri ''
(2) [perdir C:/xampp/htdocs/] rewrite '' -> '/php/index.php'
(1) [perdir C:/xampp/htdocs/] internal redirect with /php/index.php [INTERNAL REDIRECT]
(3) [perdir C:/xampp/htdocs/] strip per-dir prefix: C:/xampp/htdocs/php/index.php -> php/index.php
(3) [perdir C:/xampp/htdocs/] applying pattern '/php/index\.php' to uri 'php/index.php'
(3) [perdir C:/xampp/htdocs/] strip per-dir prefix: C:/xampp/htdocs/php/index.php -> php/index.php
(3) [perdir C:/xampp/htdocs/] applying pattern '^(/?)$' to uri 'php/index.php'
(1) [perdir C:/xampp/htdocs/] pass through C:/xampp/htdocs/php/index.php
URL=http://localhost/php/index.php
(3) [perdir C:/xampp/htdocs/] strip per-dir prefix: C:/xampp/htdocs/php/index.php -> php/index.php
(3) [perdir C:/xampp/htdocs/] applying pattern '/php/index\.php' to uri 'php/index.php'
(3) [perdir C:/xampp/htdocs/] strip per-dir prefix: C:/xampp/htdocs/php/index.php -> php/index.php
(3) [perdir C:/xampp/htdocs/] applying pattern '^(/?)$' to uri 'php/index.php'
(1) [perdir C:/xampp/htdocs/] pass through C:/xampp/htdocs/php/index.php
选项 +FollowSymlinks 重写引擎开启
RewriteRule /php/index\.php /php/error.php [L]
RewriteRule ^(/?)$ /php/index.php [QSA,L]
这里是怎么回事?
【问题讨论】:
-
您的意思是说
bla-bla.com/中的所有内容都应该重写为bla-bla.com/php/中的相同内容,但是您不希望用户能够通过直接转到bla-bla.com/php/来访问任何内容? -
这几乎是我的主要目标,但我特别希望我向 Thx 寻求回复
-
当访问者想要浏览 bla-bla.com/ 时,apache 执行并发送 php/index.php 文件,但是当访问者想要浏览 bla-bla.com/php/index.php 时,apache 执行并搜索 bla-bla.com/php/error.php 文件..
-
Is there a way to force apache to return 404 instead of 403? 的可能重复项 - 您可能正在寻找
L标志。 -
RewriteRule ^/?$ /php/index.php [L] RewriteRule ^/?php/index\.php$ /php/error.php 即使这行解决了问题..我有一个立即安装 xampp..
标签: php .htaccess mod-rewrite