开发者

mod rewrite root url

开发者 https://www.devze.com 2023-03-18 06:12 出处:网络
I\'ve been developing a site on a temporary url: http://00.00.00.00/~myurl now Ive put the site live on www.myurl.org.uk - problem is all the links on the pages don\'t resolve the temporary url

I've been developing a site on a temporary url:

 http://00.00.00.00/~myurl

now Ive put the site live on www.myurl.org.uk - problem is all the links on the pages don't resolve the temporary url is there a way to put something in the htaccess to rewrite '00.00.00.00/~myurl' as 'www.myurl.org.uk' wherever it sees occurs to save me trawlin开发者_运维技巧g the whole site - or is this bad practice?

Thanks


Rewrite rules occur after the http request, which is going to the wrong (non-existant) address. So no you can't fix this with a RewriteRule .

Also, in the future you may want to use relative links and/or a <base href=""> tag.

Edit:

I may have misunderstood your question. If http://00.00.00.00 is just the ip address of http://www.myurl.org.uk , and you want people to show the hostname rather than the ip address in their url bar, you could do something like this:

RewriteCond %{HTTP_HOST} !^www.myurl.org.uk$
RewriteRule (.*) http://www.myurl.org.uk/$1 [QSA,L,R]

Although redirecting every link click is an ugly hack, I would just fix it properly in the code.

0

精彩评论

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

关注公众号