JorgeLuisBorges
JorgeLuisBorges

Reputation: 538

mod rewrite root 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 trawling the whole site - or is this bad practice?

Thanks

Upvotes: 0

Views: 248

Answers (1)

Rob
Rob

Reputation: 8187

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.

Upvotes: 2

Related Questions