htaccess redirect question
Hi,
i have the original typolight htaccess file, but i want to add a redirect like this (the bold part):
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .*\.html$ index.php [L]
RewriteCond %{HTTP_HOST} ^subdomain.example.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
But nothing seems to work, i think maybe i have to position the code lines differently, but don't no how...
cab anyone please help?
Re: htaccess redirect question
Try it like this:
Code:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^subdomain.example.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .*\.html$ index.php [L]
[L] means "last rule", so in your example the custom rules have never been executed for .html documents. Now your rules are checked first.
Re: htaccess redirect question
Thanks, tried it but it doe'nt work.
I'll just write specific 301 page for each page.
Re: htaccess redirect question
By no means am I a mod_rewrite expert, but I wonder if the "L" at the end of both the redirect and friendly-url rules is the source of the problem. Where "L" indicates the last rule and to stop processing, as Leo said.
Change the "L" associated with your first rewrite rule to an "N" (next rule, continue processing) and give that a whirl.
Code:
...
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,N]
...
Re: htaccess redirect question
Quote:
Originally Posted by roie
Hi,
i have the original typolight htaccess file, but i want to add a redirect like this (the bold part):
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .*\.html$ index.php [L]
RewriteCond %{HTTP_HOST} ^subdomain.example.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
But nothing seems to work, i think maybe i have to position the code lines differently, but don't no how...
cab anyone please help?
To redirect for canonical url purposes use this
If what you're trying to do is redirect a sub domain to your main domain then you need to create a new htaccess file in your subdomain root folder and redirect from there, hope this helps
Nigel