Forum Moderators: phranque

Message Too Old, No Replies

Need Help With .htaccess after wordpress install

How do I redirect domain.com/wp/index.php to domain.com/wp/

         

Purposeinc

6:03 am on Dec 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi! I need help with my .htaccess
To give you a background on my htaccess knowledge level, I just learned that htaccess is just for apache servers.

Here is my current .htaccess file

RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule ^(.*)$ [domain.com...] [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(([^/]+/)*)index\.html\ HTTP/
RewriteRule index\.html$ [domain.com...] [R=301,L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /BWP/
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule . /BWP/ [L]
</IfModule>

Lines 1 through 5 were written by experts here at WebmasterWorld.
Lines 6 through 12 were written by Word Press to make my URL's pretty.
domain/BWP/ is where my word press url's are

For SEO purposes, I want all three of the below:

[domain.com...]
[domain.com...]
[domain.com...]

to 301 redirect to

www.domain.com/BWP/

What additions do I need to my old .htaccess
Due to my comeplete ignorance in this area, could you please write the final entire new .htaccess file in your reply.

If anyone sees any SEO reasons why this would be a bad idea please tell me.

Your help is most apreciated!

dk

jdMorgan

7:09 am on Dec 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> [...] could you please write the final entire new .htaccess file in your reply.

This request does not comport with our Apache Forum Charter, and I ask that you please review it here [webmasterworld.com] before we continue down this path. Thanks.

You can simply add the following at line 3:


RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /BWP/index\.php\ HTTP/
RewriteRule ^BWP/index\.php$ http://www.example.com/BWP/ [R=301,L]

However, I also suggest that you move old lines 2 and 3 below the old lines 4 and 5 to avoid a chained (double) redirect if index.html or index.php is requested from the wrong (non-canonical) domain. This would make the first part of your rewriterules look like this:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /BWP/index\.php\ HTTP/
RewriteRule ^BWP/index\.php$ http://www.example.com/BWP/ [R=301,L]
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(([^/]+/)*)index\.html\ HTTP/
RewriteRule index\.html$ http://www.example.com/%1 [R=301,L]
#
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

Also, the second "RewriteEngine on" is completely redundant, and can be safely removed. The same is true for the <IfModule> container -- you don't really need it at all.

Jim

Purposeinc

7:33 am on Dec 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry JD, for the break in protocol.

Thank you also for your advice above. I will give it a try and report back!

Thanks, so much!
dk

Purposeinc

7:48 am on Dec 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Also, for keeping track of the little htaccess file, is there a way to put comments in it. Also can you leave blank lines?

Thanks!
dk

Purposeinc

8:09 am on Dec 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Also can you tell me what you mean by module container?
Also, since htaccess is so new to me, can you suggest a very simple beginning primer on the subject?

Thanks again so much! I am off to test!
dk

Purposeinc

8:15 am on Dec 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That is great! It worked perfectly. Now I will go test and verify it gives back 301's!
dk

jdMorgan

3:11 pm on Dec 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].

Jim