i have a htaccess code shown below:
RewriteEngine On
RewriteCond $1 !^/administrator
RewriteCond %{HTTP_HOST} ^localhost/host
RewriteRule (.*) http://localhost/host/$1 [R=301,L]
RewriteRule ^([-\w]+)?/?([-\w]+)?/?([-\w]+)?/?$ index.php?seg1=$1&seg2=$2&seg3=$3
but it still read the htaccess in administrator folder. is the code incorrect?
Thanks.
RewriteCond statements apply to one RewriteRule only.
You need to repeat your RewriteConds for the second rewrite rule (and use REQUEST_URI):
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/administrator
RewriteCond %{HTTP_HOST} ^localhost/host
RewriteRule (.*) http://localhost/host/$1 [R=301,L]
RewriteCond %{REQUEST_URI} !^/administrator
RewriteCond %{HTTP_HOST} ^localhost/host
RewriteRule ^([-\w]+)?/?([-\w]+)?/?([-\w]+)?/?$ index.php?seg1=$1&seg2=$2&seg3=$3
Related
I'm currently using:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/folder/.*
RewriteCond %{REQUEST_URI} !^/folder$
RewriteRule .* https://www.newdomain.com/ [R=301,L]
Which works great at redirecting the "folder" to the "newdomain," including the files within that folder, however, the subfolders within that folder still redirect.
I've tried:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/folder/.*
RewriteCond %{REQUEST_URI} !^/folder$
RewriteCond %{REQUEST_URI} !^/folder/subfolder/.*
RewriteCond %{REQUEST_URI} !^/folder/subfolder$
RewriteRule .* https://www.newdomain.com/ [R=301,L]
As well as:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/folder/.*
RewriteCond %{REQUEST_URI} !^/folder$
RewriteCond %{REQUEST_URI} !^/subfolder/.*
RewriteCond %{REQUEST_URI} !^/subfolder$
RewriteRule .* https://www.newdomain.com/ [R=301,L]
with no luck.
Any suggestions?
You can use the following
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/subfolder.*/$ [NC]
RewriteRule .* https://www.newdomain.com/ [R=301,L]
Make sure to clear your browser cache before testing this.
I have a website, www.thesite.com and an alias www.lesite.com
i need a htaccess redirection:
I would like that, when I go to www.thesite.com/fr, it redirects me to www.lesite.com/fr
Likewise, when I go to www.lesite.com/en, I would like it to redirect me to www.thesite.com/en
I have tried different methods but i only succeed to create infinite loops !----
Options +FollowSymlinks
RewriteRule ^fr$ http://dev.mariage.ch/fr/ [L]
RewriteRule ^de$ http://dev.hortzeit.ch/de/ [L]
OR
RewriteCond %{HTTP_HOST} !^dev\.hortzeit\.ch\/de\/
RewriteRule (.*) http://dev.hortzeit.ch/de$1 [R=301,L]
RewriteCond %{HTTP_HOST} !^dev\.mariage\.ch\/fr\/
RewriteRule (.*) http://dev.mariage.ch/fr$1 [R=301,L]
You can't use path as part of RewriteCond for HTTP_HOST
instead of dev.hortzeit.ch/de you must use just host part dev.hortzeit.ch
RewriteEngine On
RewriteCond %{HTTP_HOST} !^dev\.hortzeit\.ch [NC]
RewriteRule ^de(/?.*)$ http://dev.hortzeit.ch/de$1 [R=301,NC,L]
RewriteCond %{HTTP_HOST} !^dev\.mariage\.ch [NC]
RewriteRule ^fr(/?.*)$ http://dev.mariage.ch/fr$1 [R=301,NC,L]
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 .htaccess files on every subfolder in demo.mydomain.net to redirect to mydomain.net without redirecting image/js files.
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/load
RewriteRule ^/?$ "http\:\/\/mydomain\.net" [R=301,L]
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/load/images
RewriteRule ^/?$ "http\:\/\/mydomain\.net" [R=301,L]
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/load/scripts
RewriteRule ^/?$ "http\:\/\/mydomain\.net" [R=301,L]
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/load/styles
RewriteRule ^/?$ "http\:\/\/mydomain\.net" [R=301,L]
Is there any way I can combine these to a single working file and save it to where my index file is?
You would need the following combined rule within the .htaccess in your directory mapped to demo.mydomain.net
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/load(/(images|scripts|styles))? [NC]
RewriteRule ^ http://mydomain.net [R=301,L]
The above %{REQUEST_URI} regex intercepts all four URL paths.
Let's say short.com is the short domain and long.com is the long domain
updated:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.long.com
RewriteRule (.*) http://long.com/ [R=301]
RewriteCond %{HTTP_HOST} ^short\.li$ [NC]
RewriteCond %{REQUEST_URI} !^/redirect
RewriteRule ^(.*)$ /redirect?short=$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)short\.li$
RewriteRule ^$ http://long.com/ [L,R=301]
both domains point to that root directory. When I type short.li I end up on long.com/?l=
how did I manage to screw up like that?^^
Try this in your htaccess file :
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)short\.com$
RewriteRule ^$ http://www.long.com/ [L,QSA,R=301]
Remove RewriteEngine on if it is already there
I think you might want something along the lines of this:
RewriteEngine on
RewriteCond {REQUEST_URI} !/
RewriteCond {HTTP_HOST} short.com
RewriteRule ^(.*) http://long.com/redirect.php?short=$1 [L,R=301]
RewriteCond {REQUEST_URI} /
RewriteCond {HTTP_HOST} short.com
RewriteRule ^(.*) http://long.com/ [L,R=301]
Not sure if the regex is needed on that last one or not, but something like this should work