Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Rewriting from a subfolder to the root

  • 23-04-2012 3:09pm
    #1
    Registered Users, Registered Users 2 Posts: 4,475 ✭✭✭


    Man, every time I mess around with the RewriteEngine, I just get more and more confused, no matter how much I read up on it.

    This weekend, I'll be moving my site to a new host, and am going to take the opportunity to make some changes. For the last year or so, for legacy reasons, I've had my actual site in www.domain.com/ver2/, while www.domain.com shows the original. No longer! I'm going to transfer the contents of the /ver2 subfolder on my old host to the root on my new host.

    However, there will still be links out there pointing to /ver2, so I'd like that when they come in, there's a permanent redirect to the root, but everything else is left intact. Filenames, parameters, etc etc, all as is.

    I tried
    RewriteEngine On
    RewriteBase /~domain/
    RewriteRule ^ver2/(.*)$ /$1 [R=301,NC,L]
    
    in a .htaccess in the root of my new host (and I also created a ver2 folder and popped it in there) but if I try
    http://91.216.241.2/~domain/ver2/test.php?name=michael
    
    where test.php is a file only in the root, I get 404.

    I was hoping this would do it, and then when I go live this weekend, I'd simply remove the '~domain/' part of the RewriteBase and I'm done, but instead I'm stuck. I know it's something dumb I'm doing, but no amount of Googling is helping me.


Comments

  • Closed Accounts Posts: 7,145 ✭✭✭DonkeyStyle \o/


    I'm not a whizz with .htaccess either (I pretty much hit it with a hammer until it works and hope the universe doesn't break it), but I was curious enough to have a play around with it.
    I got a 404 until I removed the forward-slash (marked in red), after which it worked as expected. The .htaccess was only in /~domain/
    RewriteEngine On
    RewriteBase /~domain/
    RewriteRule ^ver2/(.*)$ [COLOR="Red"][B]/[/B][/COLOR]$1 [R=301,NC,L]
    


  • Registered Users, Registered Users 2 Posts: 4,475 ✭✭✭corblimey


    I'm not a whizz with .htaccess either (I pretty much hit it with a hammer until it works and hope the universe doesn't break it), but I was curious enough to have a play around with it.
    I got a 404 until I removed the forward-slash (marked in red), after which it worked as expected. The .htaccess was only in /~domain/

    Hi DonkeyStyle. It was a bit difficult for me to see the red in the code section until I actually started this reply. I finally had it working with
    RewriteEngine On
    RewriteRule ^ver2/(.*)$ http://ipaddress/~domain/$1 [R=301,NC,L]
    
    but I prefer your approach. Thanks!


Advertisement