homepage Welcome to WebmasterWorld Guest from 54.161.155.142
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Modified WP htaccess rules clean?
agneslesage




msg:4234822
 8:37 am on Nov 25, 2010 (gmt 0)

Hello,

In this thread
[webmasterworld.com...]

I was asking help to insert custom redirects into my WP htaccess, and got help from JimMorgan who also put new rules to speed up the process.

There was also intervention from g1smd and am worried I did not understand everything about rule ordering and the risk of double redirects on index and default files.

Now, I ve had to simplify my rules and I've worked on it, and tested it... seems OK. But since I am far from an expert, I am worried on rules ordering and possible contradictions / mistakes.
WOuld be glad if an expert eye would tell me... and I know there are on THIS forum!

Thanks a lot for your time
Agnes


RewriteEngine on

# REWRITEBASE
RewriteBase /

# SPECIFIC REDIRECTS
# Migrating from ASP server: for any file ending .asp (default and template) redirects to HP with no string
RewriteRule .*asp(&.*)?$ http://www.atable.com? [R=301,L]
# for an old netlink "atable_traiteur" also
RewriteRule ^atable_traiteur/?$ http://www.atable.com? [R=301,L]
# for bad WSPC pages redirects to HP with strings
RewriteRule ^traiteur/?$ http://www.atable.com [R=301,L]
RewriteRule ^traiteur/unpublish/? http://www.atable.com [R=301,L]
# for wpsc category & page change
RewriteRule ^traiteur/buffets-et-cocktails/?$ http://www.atable.com [R=301,QSA,L]
RewriteRule ^traiteur/buffets-et-cocktails/buffets((/[^/]+)*)/?$ http://www.atable.com/traiteur/buffets$1 [R=301,QSA,L]
RewriteRule plateaux-de-canapes((/[^/]+)*)/?$ http://www.atable.com/traiteur/cocktails/plateaux-de-canapes-et-pieces-cocktail$1 [R=301,QSA,L]
# (more rules of same type)

# ADDITIONAL JIM MORGAN RULES:
# Redirect direct client requests for URL-path /index.php to / to avoid duplicate content
# with the exception of wp-admin directory
RewriteCond %{REQUEST_URI} !^/wp-admin/
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*(index|default)\.(php|html?|asp)([?#][^\ ]*)?\ HTTP/
RewriteRule ^(([^/]+/)*)(index|default)\.(php|html?|asp)$ http://www.atable.com/$1 [R=301,L]
# Redirect requests for non-blank, non-canonical hostnames to canonical hostname
RewriteCond %{HTTP_HOST} !^(www\.atable\.com)?$
RewriteRule ^(.*)$ http://www.atable.com/$1 [R=301,L]


# NORMAL JIM MORGAN RULES:
# if this request is for "/" or has already been rewritten to WP
RewriteCond $1 ^(index\.php)?$ [OR]
# or if request is for image, css, or js file
RewriteCond $1 \.(gif|jpg|jpeg|png|css|js|ico)$ [NC,OR]
# or if URL resolves to existing file
RewriteCond %{REQUEST_FILENAME} -f [OR]
# or if URL resolves to existing directory
RewriteCond %{REQUEST_FILENAME} -d
# then skip the rewrite to WP
RewriteRule ^(.*)$ - [S=1]
# else rewrite the request to WP
RewriteRule ^(.+)$ /index.php [L]
# END WordPress


 

sublime1




msg:4235778
 11:59 pm on Nov 27, 2010 (gmt 0)

OK, so without reading the whole deal, I'll say two things.

First, if jdMorgan and/or g1smd say it, they are right. They focus on accuracy, efficiency and on getting the job done properly.

Second, if you are using WordPress, do NOT put anything in between # BEGIN WordPress and # END WordPress -- this is a section that WP will use to write it's specific "permalink" rules. This contradicts my previous advice, since WP uses the -f and -d tests which are indeed expensive. However if you change your permalinks, WP will overwrite whatever you have put in here.

Tom

agneslesage




msg:4236176
 9:42 am on Nov 29, 2010 (gmt 0)

Ho Tom, thanks for the answer
I know these guis are right... they are so much expert I actually have trouble to follow them... The thing is I tried to reduce the number of redirects I had to deal with, thus modify some code that had been provided formerly. I just want to check I did not do sthg silly. I exactly would like to have their blessing!
Anyhow, I'll check on this begin and end wordpress, thanks!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved