Nicekiwi
Nicekiwi

Reputation: 4807

Setting a custom 404 page for a specific URL in htaccess

Can I set a 404 event to go to a page thats not 404 if its from a specific URL?

eg say I have normal users going to /404/ with:

ErrorDocument 404 /404/ 

in htaccess, and I have an admin section thats /admin/, if an admin user for whatever reason clicks a link that's invalid how-can I make them goto /admin/404/ (being a separate page from the normal 404 page) instead of /404/?

I'm guessing a rewriteCond of some kind?

Cheers

Upvotes: 0

Views: 1489

Answers (1)

Slobodan T
Slobodan T

Reputation: 22

Try something like this, it should work with some minor changes

ErrorDocument 404 /errorpage.html

RewriteCond %{REQUEST_URI} ^/admin/$ [NC]
RewriteRule errorpage.html /errorpage_admin.html [L]

Upvotes: 1

Related Questions