views:

81

answers:

1

hi,

can that be possible in mod rewrite? for example (mydomainname.com/myadmin) to (myadmin.mydomain.com)? how to write that in mod rewrite? so whenever the access the mydomainname.com/myadmin they get an error message of not existing.

Thanks!

--Edited---------

Sorry for that. In my website I have an admin (/myadmin) section where only moderators and administrator can access. Now there are a lot of user keep accessing it and I want to change the URL of it. Now instead of 'www.mydomain.com/MyAdmin' it would be 'MyAdmin.mydomain.com'. So whenever they go to 'www.mydomain.com/MyAdmin' they wouldn't find anything.

I just know that htaccess can do url rewriting, But I don't know how to write one.

Thank You!

+1  A: 

Try these rules:

RewriteCond %{THE_REQUEST} ^[A-Z]+\ /myadmin[/\s] [NC]
RewriteRule ^myadmin - [NC,L,R=404]

RewriteCond %{HTTP_HOST} =myadmin.example.com [NC]
RewriteRule !^myadmin/ /absolute/filesystem/path/to/myadmin%{REQUEST_URI} [L]

That will result in a 404 response when requesting /myadmin. And myadmin.example.com will be internally rewritten to that specific myadmin directory if accessible through the file system.

Gumbo
Hi Gumbo,I've been trying to test the code but have no luck to make it work.here's what i've write in my .htaccess. RewriteCond %{THE_REQUEST} ^[A-Z]+\ /myadmin[/\s] [NC]RewriteRule ^myadmin - [NC,L,R=404]RewriteCond %{HTTP_HOST} =myadmin.movietunie.com [NC]RewriteRule !^myadmin/ /home/movietun/public_html/movie_tunie/myadmin/%{REQUEST_URI} [L]is there wrong with my code?my site is http://movietunie.com and myadmin.movietunie.comI still can access the http://movietunie.com/myadmin, why is that?Thank You!
Pennf0lio
@Pennf0lio: REQUEST_URI already starts with a `/`. Try it without the `/` before `%{REQUEST_URI}`.
Gumbo