redirecting with .htaccess

Discussion in 'Programming/Scripts' started by David91, Aug 9, 2007.

  1. David91

    David91 New Member

    redirecting with .htaccess?


    im new here and i have no skill in programming at all, im simply doing this to get my website working correctally.

    The Full story:
    My website is but because if the way it is configured and they way my domain ( is set up and the way that the we host is set up i cant link my domain to my webspace. so
    instead they have linked it to the main page. which is (which is a friends website/main page) My friend has given me a folder in his webspace to use as a blog and seen as i cant direct my domain to my folder/blog (because of an issue i cant fix) i am looking for a script/code to redirect people who imput into my blog/folder. i know that this can be done using htaccess but i am useless at coding an unfortunatly i cannot fix it. My friend (the owner of the website) thought of this code:

    although it failed to work and gave the user an internal server error (500)
    So im looking for a peice of code to make this work. any ideas?

    just to recap:
    im looking for a peice of code to redirect people who enter into their brower to

    Thanks for any help offered
    Last edited: Aug 9, 2007
  2. geekman

    geekman New Member

    Why not just create an index.html page at like so:
            <META HTTP-EQUIV="Refresh" CONTENT="0; URL=">
            <a href="">If you are not redirected click here.</a<
    Should work fine for you.
  3. David91

    David91 New Member

    thing is that is only a domain, there is no hosting on it, so all the hosting is on so unfortunatly i cant do as youve described, thanks for the help though.

    Any other ideas?
  4. falko

    falko Super Moderator ISPConfig Developer

    Try something like this:

    RewriteEngine on
    RewriteCond   %{HTTP_HOST}                 ^www\.[^.]+\.davidoboyle\.co\.uk$
    RewriteRule   ^(/~.+)$1 [R,L]
  5. David91

    David91 New Member

    thanks for all the help.

    i tried your code with our server and nothing happened. it doesnt redirect me and it doent destroy the server with a 500 error. i then added the line

    to the top like the other code has and it gave us a 500 error again. whats is this code used for? is it incompatable with our server or isnt it written properly?
  6. falko

    falko Super Moderator ISPConfig Developer

    Are there any errors in Apache's error log?
  7. David91

    David91 New Member

    sorry for not posting this before, i found them and i just forgot.

    here is it

  8. David91

    David91 New Member

    bump (sorry) :p
  9. falko

    falko Super Moderator ISPConfig Developer

    Please remove the order line from .htaccess. Then direct your browser to (not What happens?
  10. David91

    David91 New Member

    when i remove the "order deny,allow" line and enter into my browser it just goes to the main page (the same location that points to)
  11. edge

    edge Active Member Moderator

    Try this in your .htaccess file
    RewriteEngine on
    RewriteBase /
    RewriteCond %{HTTP_HOST} www.davidoboyle\.co\.uk
    RewriteRule (.*) http://seriesoftubes\.co\.uk/david/index.html$1 [R=301,L]
    RewriteCond %{HTTP_HOST} davidoboyle\.co\.uk
    RewriteRule (.*) http://seriesoftubes\.co\.uk/david/index.html$1 [R=301,L]
    Last edited: Aug 13, 2007
  12. David91

    David91 New Member

    Thanks so much edge!

    seems thats sorted it. well it actually redirects me to /index.html when mines /index.php but ive made a quick instant redirect page to link between the two.

    so the problem is solved thanks :)

    this topic can be closed or whatever
  13. David91

    David91 New Member

    hello again =)

    the script still works (thanks again) but now im in abit of a problem. if i want to make a redirect to a subfolder its screws up and therefore doesnt work.

    for example if i wanted and i type in "" into my browser i get the error message

    and the URL has changed in the address bar to

    Anyway of getting round this? like adding another Htaccess command or somthing so i could have a subdomain in ""?

    thanks again for the help :)
  14. David91

    David91 New Member

    Bump (sorry) :D
  15. falcunix

    falcunix New Member

    i think , if you just want to redirect to other page, can use

    Redirect /
  16. David91

    David91 New Member

    i dont quite follow you.

    i wanna be able to redirect page C to D without interfering with the code to redirect pages A to B. and if i add another redirect into my .htaccess file it seems to screw the whole thing up.

    thanks for any help :)

Share This Page