Reputation: 1024
Well, I am using .htaccess rules to edit my website url structure. Now, I have following url :
http://localhost/aponit/dev/zones
This url is for zones.php page to edit a form data. After click on edit link it will go to this link :
http://localhost/aponit/dev/zones/update/55
This link is open on update.php
page.
Now, If I remove following part from this url
/55 or date/55
then it's showing me error message with appropriate error page. That fine.
But if I remove update/55
from the url then url is look like that :
http://localhost/aponit/dev/zones/ (note the forward slash at the end)
then it's calling zones.php page and stylesheet is broken
BUT I want to show a error page e.g : not-found.php page. How can I do this using .htaccess ?
My .htaccess rules :
Options -MultiViews
ErrorDocument 404 http://localhost/aponit/dev/not-found.php
ErrorDocument 500 http://localhost/aponit/dev/404.php
RewriteEngine on
RewriteRule ^(?:zones/)?update/(\w+)/?$ update.php?z=$1 [L,QSA,NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
Upvotes: 1
Views: 185
Reputation: 785128
You can use:
Options -MultiViews
ErrorDocument 404 /aponit/dev/not-found.php
ErrorDocument 500 http://localhost/aponit/dev/404.php
RewriteEngine on
RewriteRule ^zones/$ - [NC,L,R=404]
RewriteRule ^(?:zones/)?update/(\w+)/?$ update.php?z=$1 [L,QSA,NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
Upvotes: 1