1

I need to redirect a page on a client site to an outside URL. I have been using the following redirect, which works - sort of:

redirect 301 /durhamchapelhill http://gds.chapelhilluumc.org

The problem is that the resulting URL is cluttered:

http://gds.chapelhilluumc.org/?/durhamchapelhill

I sought help on StackOverflow and got a really good redirect

RewriteEngine On
RewriteBase /

RewriteRule ^durhamchapelhill$ http://gds.chapelhilluumc.org [R]

By itself, it does an awesome job and returns a nice clean URL. Which brings up the thorny issue of hiding the index.php page.

Before all of this started I was using the following to hide index.php and it works great:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

The problem is I need both (hide index.php and redirect).

Here is the combination I tried:

RewriteEngine On
RewriteBase /

RewriteRule ^durhamchapelhill$ http://gds.chapelhilluumc.org [R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

However, if I combine the two rules the redirect fails.

Is there an htaccess doctor in the house that can assist with setting this straight?

Thanks!

1

1 Answer 1

1

Here are three variations to try:

RewriteRule ^durhamchapelhill$ http://gds.chapelhilluumc.org [R,L]

OR

RewriteRule ^durhamchapelhill http://gds.chapelhilluumc.org [R,L]

OR

RewriteRule ^durhamchapelhill(.*)$ http://gds.chapelhilluumc.org$1 [R,L]
2
  • It was The last one. Thank you for the options.
    – forrest
    Feb 27, 2013 at 21:12
  • Great! Glad you got it sorted.
    – Anna_MediaGirl
    Feb 27, 2013 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.