skip to Main Content

I have folder admin
And I have changed url from admin to admin-cdn with below rule

RewriteRule ^admin-cdn/?(.*)$ admin/$1 [L]

Now I can access admin folder’s files with both www.domain.com/admin/ and www.domain.com/admin-cdn/ url

I want show 404 error when user what to access with www.domain.com/admin path

How can do this in .htaccess file

2

Answers


  1. Try this

    RewriteRule ^admin/ - [L,R=404]
    RewriteRule ^admin-cdn/?(.*)$ admin/$1 [L]
    
    Login or Signup to reply.
  2. You can do it like this:

    RewriteEngine On
    
    # if /admin/ is entered as URL then send 404
    RewriteCond %{THE_REQUEST} s/admin[?/s] [NC]
    RewriteRule ^ - [L,R=404]
    
    # internal rewrite from /admin-cdn/ to /admin/
    RewriteRule ^admin-cdn(/.*)?$ admin$1 [L,NC]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search