Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.htaccess 404 error on real path

I want the following:

  1. www.bla-bla.com/ --> www.bla-bla.com/php/index.php
  2. www.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?

like image 437
Chris P Avatar asked Dec 20 '25 07:12

Chris P


1 Answers

use

ErrorDocument 404 /php/error.php

in .htaccess file

like image 137
Shailesh Jangir Avatar answered Dec 22 '25 21:12

Shailesh Jangir



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!