Page is a not externally linkable
- Code, Content, and Presentation
-- Apache Web Server
---- Simple 301 redirect and Wordpress htaccess rules


agneslesage - 6:39 am on Nov 25, 2010 (gmt 0)


Hello

Ok, I think I managed to get together Jim Morgan's "normal" rules and the addiotional ones provided in this post, and to get it all to work locally, with the following code.

Other questions I'll get on another post!


RewriteEngine on

# REWRITEBASE

# may be online (www.atable.com) or local (http://localhost/www-atable-new.com)
### local
RewriteBase /www.atable-new.com/
### online
## RewriteBase /


# 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
### local
RewriteCond %{REQUEST_URI} !^/www.atable-new.com/wp-admin/
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*(index|default)\.(php|html?|asp)([?#][^\ ]*)?\ HTTP/
RewriteRule ^(([^/]+/)*)(index|default)\.(php|html?|asp)$ http://localhost/www.atable-new.com/$1 [R=301,L]
### online
## 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
### local - I don't get it to work
### online
## 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

# FINISH TO WP

### local with normal Jim Morgan's rules
RewriteRule . /www.atable-new.com/index.php [L]

### online with normal Jim Morgan's rules
## RewriteRule . /index.php [L]

### online with additional Jim Morgan's rules
## RewriteRule ^(.+)$ /index.php [L]

# END WordPress


Thread source:: http://www.webmasterworld.com/apache/4182512.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com