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


agneslesage - 7:02 pm on Nov 24, 2010 (gmt 0)


Hello
Here is the answer, provided by Dardna who also made a plugin using your code

[dardna.com...]

RewriteEngine on
# Unless you have set a different RewriteBase preceding this point,
# you may delete or comment-out the following RewriteBase directive:
RewriteBase /www.mysite.com/
# 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 . /www.mysite.com/index.php [L]
# END WordPress

This now works!

I guess I only have to see how to refusion everything now...

2 little questions though:

- I want to insert a few redirect rules for specific files or directories - where should I do that?
Just after this line?

RewriteRule ^index\.php$ - [L]

NB: I will simplify the former rules with a single redirect for my old web site whose all files started with either default.asp or template.asp somehtings
RewriteRule ^default\.asp$ [localhost...] [R=301,L]
RewriteRule ^template [localhost...] [R=301,L]
NB: this probably may even been done saying "anything.asp followed by anything"...?
This leads me to my second question

2> What is the best string for saying "any URL containing"...

You told me when it is in the string:
Query string contains name/value pair "page=qui_nous" : ^([^&]*&)*page=qui_nous(&.*)?$
Nopw for what is in a URL, is it the same?
I ghet some error 500 when I do

# RewriteRule ^([^&]*&)*specialites-italiennes((/[^/]+)*)/?$ [localhost...] [R=301,L]

Ideally, I'd like to say
"any URL containing X" redirects to "www.mysite.com/Y"
"and if it contains X followed by Z" redirects to www.mysite.com/Y/Z including any attached string"

You see what I mean?
(talking chinese, no!)

Agnes


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