Falcon
Falcon

Reputation: 259

Prevent file access from actual url and use rewrite .htaccess

i have a situation here for htaccess. I'm fairly new to htaccess. So, am using codeigniter. Now i wanna do a redirect.

The origional url for codeigniter is:

www.mysite.com/index.php/admin/getz

Now, i wanna have user type www.mysite.com/agetz to access the above url. fairly fine till now. It does it by:

RewriteRule ^agetz$ /index.php/admin/getz [L]

Now, what i wanna do is that when people type the real url i.e. www.mysite.com/index.php/admin/getz, i want to redirect them to 404 page(secure the url from others for some security reasons), and when they type www.mysite.com/agetz, i want to allow them the accesss to getz controller.

Problem is that currently if i do any trick to kick anyone typing url www.mysite.com/index.php/admin/agetz to 404, it also kicks mysite.com/getz. Have to do it with .htaccess.

Upvotes: 1

Views: 430

Answers (1)

anubhava
anubhava

Reputation: 784998

Replace your existing code with this:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index\.php/admin/getz/?[\s\?] [NC]
RewriteRule ^ - [R=404,L]

RewriteRule ^agetz/?$ /index.php/admin/getz [L,NC]

Upvotes: 1

Related Questions