Link to home
Start Free TrialLog in
Avatar of Chris Andrews
Chris AndrewsFlag for United States of America

asked on

.htaccess redirect help needed

The old version of my site had pages in a directory:

http://www.mysite.com/dir/page1.html
http://www.mysite.com/dir/subdir/page2.html

etc.....

I need to direct any traffic going to anything in those directories, either the main or the subdirectory, to my new wordpress page, which is at:

http://www.mysite.com/dir/    (yep, in wordpress, that's a page, not a real directory, not sure how that works). Using the permalinks option to do that.

What would I put in my .htaccess file to do this?

Thanks,

Chris
Avatar of Kent Dyer
Kent Dyer
Flag of United States of America image

You mean something like:
RewriteCond %{HTTP_HOST} ^mysite.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.mysite.com$
RewriteRule ^/?$ "http\:\/\/www\.mysite\.com\/subdir/page.htm" [R=301,L]

Open in new window


HTH,

Kent
ASKER CERTIFIED SOLUTION
Avatar of Jason C. Levine
Jason C. Levine
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Chris Andrews

ASKER

RewriteRule ^dir/(.*)$ /dir/ [L,R=301]

Looks to be the most efficient way to do this - and it works to redirect to /dir/ - but when it does, I get an error page saying there were too many redirects. (redirect loop)

I'm sorry, I should have included this before, but my current .htaccess has this in it:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

(from what the permalink wp page gave me to enter in it)

Any line I put the redirect on that worked (redirected) gave me an error when it got to the actual www.mysite.com/dir/ page.

Chris
Got this worked out, thank you.