开发者

Mod rewriting? slash to subdomain possible?

开发者 https://www.devze.com 2022-12-07 23:56 出处:网络
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

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' t开发者_运维问答hey wouldn't find anything.

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

Thank You!


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消