简体   繁体   中英

htaccess mask for my url

I'm trying to mask a part of my url using .htaccess but I'm having several issues

my url is http://ristorantitalianetwork.com/ristorantitalianetwork.com/admin/

I'd like to remove the duplicate ristorantitalianetwork.com, so I'd like that my url will be like

http://ristorantitalianetwork.com/admin/

I've used

RewriteRule ^ristorantitalianetwork.com/([^/]*)$ ?q=$1 [L] 

but it doesn't work

Could you please help me to figure out how to solve this problem?

Thanks a lot

Best regards

You really need

RewriteRule ^/admin$ /ristorantitalianetwork.com/admin [L] 

Bear in mind that the URL you should expose to users is http://ristorantitalianetwork.com/admin/ which will then internally get converted (rewritten) to http://ristorantitalianetwork.com/ristorantitalianetwork.com/admin/ .

It is not the other way round as many believe.

You almost did it! But...

In your question, your rewriterule says that it is applied on URLs that don't end with a slash ( / ). And you say you want to rewrite some URLs... and give URLs examples with a slash ( / ).

If you need to do a real redirect (ie the URL in the browser changes):, here's the good rewriterule:

RewriteRule ^ristorantitalianetwork\.com/([^/]*)/$ /$1 [QSA,R=301,L]

If you need to do only internal redirect:

RewriteRule ^ristorantitalianetwork\.com/([^/]*)/$ /$1 [QSA,L]

Keep in mind that the URL must end with a slash ( / ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM