Forum Moderators: phranque
i have to redirect punters to the index.html file on a site, i have successfully set up a redirect to a different site, while allowing my own IP in to the index.php file, but now i want to simply redirect everyone else to index.html but i cant get it to work!
this is the working redirect to send them elsewhere
RewriteCond %{HTTP_HOST} ^(www\.)?currentsite\.com [NC]
RewriteRule ^(.*)$ [elsewhere.co.uk...] [R=301,L]
Redirect 301 "index.php" [elsewhere.co.uk...]
the above sends people away to the elsewhere site, but now i just want them to go to index.html
thanks for your time...
Generally, if you use mod_rewrite for *any* redirects, then your should use it for *all* redirects.
This is because, on any given server, each module looks at your directives in turn, executing only the directives that it understands. So, the directives in your .htaccess file are *not* executed sequentially, but rather in per-module order. And unless you configured the server, you cannot know whether mod_rewrite or mod_alias directives will execute first. And if you change hosts, this could change as well...
Jim
Please post your best-effort code --with comments-- as a basis for discussion. As you know, we'll be happy to help you get your own code working, but we don't offer a 'free coding service' here.
Jim
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com [NC]
RewriteRule ^(.*)$ http://www.example.co.uk/$1 [R=301,L]
Redirect 301 "index.php" http://www.example.co.uk
i just changed the url to anonymous ones. I also have a little bit before that that allows my IP address access
what i want to do, is redirect people to index.html on the domain www.example.com while allowing myself access to index.php, the domain will be example.com
i have tried a lot of messing about with this over the course of today, but all i manage to do is get server configuration errors or a loop. I realise this isnt a free coding service, and i apologise for using it as one.
[edited by: jdMorgan at 6:30 pm (utc) on Dec. 29, 2008]
[edit reason] No URLs. Please see terms of Service and Forum Charter. [/edit]
RewriteCond %{REMOTE_ADDR} !^my\.ip\.address\.here
RewriteRule (.*) http://www.example.co.uk/example.html$1 [R=301,L]
RewriteRule /index.php$ http://www.example.co.uk/example.html [R=301,L]
i dont 'do' coding, i do this to save the company some money, so i expect its horribly wrong, which is why i posted here, i wasnt asking for someone to code it, i was asking for a little help, but eventually after a lot of frustration, time and googling, i found something that worked.
However
Any improvements would be gratefully received.
A simple typo could make your site inaccessible to Google, or to all customers using a certain type of browser, or any other such disaster.
You need to be very clear as to what every bit of every line of code is supposed to do, and what it actually does, before making any such changes to your site.