I want the following:
www.bla-bla.com/–>www.bla-bla.com/php/index.phpwww.bla-bla.com/php/index.php–>www.bla-bla.com/php/error.php
I have tried the following but doesn’t work
RewriteEngine on
RewriteRule ^/?$ /php/index.php [S=1]
RewriteCond %{REQUEST_URI} =/php/index\.php
RewriteRule (.*)? /php/error.php [R=404]
What can I do to deny access from real path?
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
Options +FollowSymlinks
RewriteEngine on
RewriteRule /php/index\.php /php/error.php [L]
RewriteRule ^(/?)$ /php/index.php [QSA,L]
Wtf is going on here?
Try this:
EDIT: responding to comments:
Without the[L] flag, it will try to apply the next rule. mod_rewrite will always send it back through the rewrite engine after a URI has been rewritten. It will continue to do so until the URI went through the engine unchanged. The first condition checks that the actual request is for
/php/index.php, so that the rewritten URI won’t match. Example:GET / HTTP/1.1GET / HTTP/1.1Example 2:
GET /php/index.php HTTP/1.1/php/error.php