Forum Moderators: phranque
RewriteEngine on
RewriteCond %{HTTP_HOST} ^theenchantedimage\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.theenchantedimage\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/\blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /\blog/$1
RewriteCond %{HTTP_HOST} ^(www.)theenchantedimage.com$ [NC]
RewriteRule ^(/)?$ blog/index.php [L] <IfModule mod_rewrite.c> to avoid searches going to the website I will be hosting on the root directory but I haven't been able to figure this out. Any help would be greatly appreciated as I am have been pulling my hair out trying to figure this one out and it just doesn't matter how many articles I read I can't get it to work. Also, since my blog was originally hosted on my root I have to have the .htaccess file in the root directory of my FTP to handle any of the broken links. RewriteCond %{HTTP_HOST} ^theenchantedimage\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.theenchantedimage\.com$ [NC] RewriteCond %{HTTP_HOST} ^(www\.)?theenchantedimage\.com$ [NC] ^(.*)$ The code below is also redirecting
Why are you escaping the b of blog as \blog here?
RewriteRule {blahblah} http://www.example.com/{otherblahblah} [R=301,L] RewriteRule {blahblah} {otherblahblah} [L] RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?theenchantedimage\.com$ [NC]
RewriteCond %{REQUEST_URI} !^\/blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule {blahblah} http://www.blog.theenchantedimage.com/{otherblahblah} [R=301,L]
Here is an example of what the two different links look like that are going to be coming in.
1) www.example.com/YYYY/MM/DD/Post-Name/
2) www.example.com/blog/YYYY/MM/DD/Post-Name/
I need to REDIRECT these cases to the following construction:
www.blog.example.com/YYYY/MM/DD/Post-Name/
...
RewriteCond %{REQUEST_URI} !^/blog/
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC]
RewriteRule ^(?:blog/)?(\d\d\d\d/\d\d/\d\d/postname/){morestuff} http://www.example.com/$1 [R=301,L] Note the {morestuff}. Can anything come after the Post-Name-plus-slash?
Will it always be the same?
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC]
RewriteRule ^(?:blog/)?(\d\d\d\d/\d\d/\d\d/postname/){morestuff} http://www.example.com/$1 [R=301,L] http://www.example.com/$1 to http://www.blog.example.com/$1? RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?theenchantedimage\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/blog/
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC]
RewriteRule ^(?:blog/)?(\d\d\d\d/\d\d/\d\d/postname/){morestuff} http://www.example.com/$1 [R=301,L] Which pattern is correct?
Here is an example of what the two different links look like that are going to be coming in.
1) www.example.com/YYYY/MM/DD/Post-Name/
2) www.example.com/blog/YYYY/MM/DD/Post-Name/
RewriteCond %{REQUEST_URI} !^/blog/ -- DO NOT redirect if path begins "/blog/"
RewriteRule ^(?:blog/) -- DO redirect if path begins "/blog/"
I saw the English here stating that the {REQUEST_URI} means DO NOT redirect if path begins with /blog/. Will this RewriteCond work with in each of the following paths?
1) www.theenchantedimage.com/YYYY/MM/DD/PostName/
2) www.theenchantedimage.com/blog/YYYY/MM/DD/PostName/
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^(www\.)?theenchantedimage\.com$ [NC]
RewriteRule ^(?:blog/)?(\d\d\d\d/\d\d/\d\d/[^/]+/) http://www.blog.theenchantedimage.com/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{HTTP_HOST} ^(www\.)?theenchantedimage\.com$ [NC]
RewriteRule ^(?:blog/)?(\d\d\d\d/\d\d/\d\d/[^/]+/) http://www.blog.theenchantedimage.com/$1 [R=301,L]