简体   繁体   中英

htaccess Redirect a folder to a new URL

I have the following code:

Redirect /email http://email.secureserver.net

Which doesn't seem to be working. Basically, I need to be able to redirect someone when they go to www.thedomain.com/email/ to http://email.secureserver.net

Now I want this to be able to work on my testing server and also when it goes live so I don't have to change the code.

So for testing the URL will be something like:

www.testingserver.com/clients/drews-garage/live/email/

And for when it goes live it will be:

www.thedomain.com/email/

So based on the code I provided above, that should work either way but it doesn't seem to work on my testing server. I tried a 301 redirect to.

Anyone have any ideas?

Thanks!

I suggest you to use mod_rewrite 's RewriteRule . Rather than mod_alias 's redirect .

RewriteCond %{Request_URI} /email/?$
RewriteRule ^ http://email.secureserver.net [L,R=301]

The above will match email/ in your URI path. So, clients/drews-garage/live/email/ as well as email/ will be matched.


Redirect /email http://email.secureserver.net

Is not working because of your URL: www.testingserver.com/clients/drews-garage/live/email/

The above is trying to redirect www.testingserver.com/email/

or mod_alias might not be loaded. But, mod_alias is usually loaded by default so this case is very unlikely.

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