Saturday, 15 August 2015

.htaccess - Show a custom page for notfound folders -


I want to do this, for example a custom page sub.php, whenever no URL was found

< P> For example

  http://domain.com/blabla/ http://domain.com/blabla/bladas.html http://domain.com/tedabad/dasd/ Sadsad /  

then all the above example URLs are not found, which I would like to display the contents of http://domain.com/sub.php I have tried the following code, but its not working

 RewriteBase / RewriteCond% RewriteEngine on current  option + FollowSymLinks -Mu LtiViews # turn mod_rewrite! {} REQUEST_FILENAME -d [OR] RewriteCond% {REQUEST_FILENAME}! -f [or] RewriteCond% {REQUEST_FILENAME} -l RewriteRule ^ - !? (?? +) [L] RewriteRule ^ ([^ /] +) / $ /sub.php [L] RewriteRule ^ ([^ /] + / /? Text after "$ / $ 1sub.php [L]  

You can check for presence Use a revertcut and a errorDocument command in sub.php :

 Options at RewriteCond% + FollowSymLinks -MultiViewsRewriteEngine {REQUEST_FILENAME}! -d RewriteCond% {DOCUMENT_ROOT} / $ 1 / sub \ .php -f [nc] RewriteRule ^ ([^ /] +) / (. +?) /? $ / $ 1sub.php [L] RewriteCond% {REQUEST_FILENAME}! -d RewriteCond% {REQUEST_FILENAME}! -f RewriteRule /sub.php [L]  

No comments:

Post a Comment