I have a problem with an redirect exception.
All the files in root were redirected to /
I want create a exception for the sitemap.xml.
My htaccess :
RewriteCond %{HTTP_HOST} ^www.website.com$
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{REQUEST_URI} !sitemap.xml$
RewriteRule ^(.*)$ site/web/website/index.php [L]
RewriteCond %{HTTP_HOST} ^www.website.com$
RewriteCond %{REQUEST_URI} ^/site/web/website/$
RewriteCond %{REQUEST_URI} !sitemap.xml$
RewriteRule .* http://www.website.com/ [R=301,L]
RewriteCond %{HTTP_HOST} ^website.com$
RewriteCond %{REQUEST_URI} ^/site/web/website/$
RewriteRule .* http://www.website.com/ [R=301,L]
But does not work :(.
Many thanks
Related
I have a task - all somestuff.html/ pages with trailing slash must redirect to somestuff.html and all other pages without a trailing slash must redirect to add a trailing slash (e.g. /mypage must redirect to /mypage/). I have accomplished the task but now /administrator/ page returns 404 page. I tried to exclude the /administrator/ page but its not working:
DirectoryIndex index.php
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#this part breaks the admin panel entry
RewriteRule ^([^.]+).html/ http://somedomain.com/$1\.html [R=301,L]
RewriteCond %{REQUEST_URI} !\.(php|html?|jpg|gif)$
#trying to exclude administrator page
RewriteCond %{REQUEST_URI} !^/administrator/
RewriteRule ^(.*)([^/])$ http://%{HTTP_HOST}/$1$2/ [L,R=301]
#end of part that breaks the admin panel entry
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
Can anyone tell me what I am doing wrong or maybe offer some different solution to acocmplish the redirecting. Thanks.
Found a solution:
DirectoryIndex index.php
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+).html/ http://logosstudy.ru/$1\.html [R=301,L]
RewriteCond %{REQUEST_URI} !^/administrator/
RewriteCond %{REQUEST_URI} !\.(php|html?|jpg|gif)$
RewriteRule ^(.*)([^/])$ http://%{HTTP_HOST}/$1$2/ [L,R=301]
RewriteCond %{REQUEST_URI} !^/administrator/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
I have
sub.domain.com and want it to be redirected to domain.com
But there must not be redirects from e.g. sub.domain.com/folder/ or sub.domain.com/folder/index.html
Everything i've tried does not work...
For example
RewriteEngine on
RewriteCond %{HTTP_HOST} sub.domain\.com [NC]
RewriteCond %{REQUEST_URI} ^/$
Rewriterule ^(.*)$ http://www.domain.com/ [L,R=301]
You can use this :
RewriteEngine on
RewriteCond %{HTTP_HOST} sub.domain\.com [NC]
RewriteCond %{REQUEST_URI} !^/folder/?$
RewriteCond %{REQUEST_URI} !^/folder/index\.html$
Rewriterule ^(.*)$ http://www.domain.com/ [L,R=301]
i want to redirect
http://subdomain.example.com/index.php?pageID=45
to
http://example.com/subdomain/45.html
Please help me with this
i tried
RewriteCond %{HTTP_HOST} ^(www\.)?subdomain\.example\.com$ [NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ http://www.example.com/sudomain/$1 [L,R=301]
You can replace your code by this one in your htaccess (in root folder)
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain\.example\.com$ [NC]
RewriteCond %{QUERY_STRING} ^pageID=([1-9][0-9]*)$ [NC]
RewriteRule ^index\.php$ http://example.com/subdomain/%1.html? [R=301,L]
I have question how to redirect this link:
http://rude.su.lt/~veikutis/katalogas.php?link=dulkiu-siurbliai&id=1
To this link:
http://rude.su.lt/~veikutis/dulkiu-siurbliai/1/
With htaccess 301 redirect?
Add this to your .htaccess in DocumentRoot.
RewriteEngine On
RewriteBase /
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\.\w+$
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) /$1/ [R,L]
RewriteCond %{REQUEST_URI} ^/(\~veikutis)/([\w\d-]+)/([\d-]+)/$ [NC]
RewriteRule ^ /%1/katalogas.php?link=%2&id=%3 [L,QSA]
RewriteCond %{QUERY_STRING} !^$
RewriteCond %{QUERY_STRING} flink=([\w\d-]+)&id=(\d+) [NC]
RewriteRule ^(~veikutis) /$1/%1/%2/? [L,R]
I have htaccess like below, it includes admin also but I don't want htaccess to effect my admin area, so what changes should I do in below code?
RewriteEngine On
RewriteBase /
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]
RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !\.\w+$
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) /$1/ [R,L]
RewriteCond %{REQUEST_URI} ^/(my_site)/([\w\d-]+)/$ [NC]
RewriteRule ^ /%1/?file_name=%2 [L,QSA]
RewriteCond %{QUERY_STRING} !^$
RewriteCond %{QUERY_STRING} file_name=([\w\d-]+) [NC]
RewriteRule ^(my_site) /$1/%1/? [L,R]
Previous conversation: Redirection through htaccess not working
Thanks in advance.
Add the first line.
RewriteCond %{REQUEST_URI} !/admin
RewriteCond %{REQUEST_URI} ^/(my_site)/([\w\d-]+)/$ [NC]
RewriteRule ^ %1/?file_name=%2 [L,QSA]