Trying to figure out how to get the following rewrite rule changed to work with Litespeed.
Previously the below rewrite rule worked with Apache, but stopped working with Litespeed.
RewriteRule ^product-page/category-one/ index-redir.php
[L,E=URI:/category-one/]
RewriteRule ^category-one/ /product-page/category-one/
[R=301,L]
Related
I have a rewrite rule to hide index.php, which is
working fine.
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
I am currently redirecting a specific sub-domain to another domain.
RewriteCond %{HTTP_HOST} ^(www\.)?deutschland\.example\.com$ [NC]
RewriteRule ^ http://www.example.de%{REQUEST_URI} [NE,R=301,L]
The redirect is working fine, but now I am getting index.php in the URL too, which is coming in the REQUEST_URI.
http://www.example.de/index.php/search/result
So how to remove 'index.php' from this redirected URL?
Note: Its the same php website application only, just using country-wise multiple domains.
(1) Rule order is important. (2) the last flag doesn't mean last; it means last on this cycle. (From Apache 2.4 the end flag does what you might think last does. See my Tips for debugging .htaccess rewrite rules for more discussion of this). So in this case rule(1) fires and then mod_rewrite loops around again and this time rule (2) fires giving what you find.
Swap the two rules around and it will work as expected.
I am trying to redirect a link ONLY if it's www.domain to a subdomain admin.domain I have been looking around and I am thinking it's my syntax messing me up. I am not so great with .htaccess redirects and rewrites. Here is what I have used so far.
Example 1
RewriteCond %{HTTP_HOST} !^www.mydomain.com$
RedirectMatch 301 ^/wp-admin/?(.*)$ http://admin.mydomain.com/wp-admin/$1
Here is the second on I also have been trying.
RewriteCond %{HTTP_HOST} !^www.mydomain.com$
RewriteRule ^/wp-admin/(.*)$ http://admin.mydomain.com/wp-admin/$1 [QSA,L,R=301]
This is working off an amazon AWS cluster so the code needs to stop once it rewrites only with www. That is where the loop keeps happening.
Any help would be deeply appreciated!
I think you got it backwards, you want to redirect IF the host is www.mydomain.com, not when it ISN'T. So get rid of the !:
RewriteCond %{HTTP_HOST} ^www.mydomain.com$ [NC]
RewriteRule ^/?wp-admin/(.*)$ http://admin.mydomain.com/wp-admin/$1 [QSA,L,R=301]
Note that the first code block you have won't work at all. You're using a mod_rewrite condition with a mod_alias directive, they're completely independent of each other.
There are so many examples on Stack, but I can't get this working for my site.
I need to rewrite this
http://www.example.com/folder/nicelooking-page/page/4
to this
http://www.example.com/folder/nice/page/4
I thought this would work, but it didn't
RewriteRule ^/folder/nicelooking-page/(.*)$ /folder/nice/$1 [L,QSA,R=301]
RewriteRule ^/?folder/nicelooking-page/page/(.*)$ /folder/nice/page/$1 [L,QSA,R=301]
You had page missing in rewrite rule.
I have rewritten a rule for URL rewriting but when i try to access the website admin panel, server shows me 404 error whereas front-end working with rewriting rule.
following rule are written
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
for admin panel
RewriteRule ^admin/page/([a-zA-Z0-9_-]+)\.html$ admin/page.php?page=$1
RewriteRule ^admin/page/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/(.*)$ admin/page.php?page=$1&$2=$3
For frontend
RewriteRule ^(.*)\.html$ $1.php [nc]
Though for front-end rule working fine and i can access the website using www.blabla.com/index.html. Written rule automatically convert the .php file into .html
Moreover these rule are working fine in my localhost and UAT server but on production server these rules do not work.
Any one can suggest what wrong i am doing or is there something with .htaccess or mod_rewrite where i can do some tweaks.
Suggest please.....
I've got a .htaccess file that has got a rewrite rule in it as follows which works fine:
RewriteRule ^solicitorsin([^/]+)/all/([0-9]+)$ /search/searchresults.php?county=$1&page=$2 [L]
What I'm looking to do is to keep using this for if the page variable is 2 or higher, but if it's 1 I want to 301 redirect to a separate url (the same site) say http://www.domain.com/solicitorsinCOUNTY/
The problem is that if I try doing this using a 301 redirect or a rewrite rule it still performs the above rewrite rule as well so I end up with http://www.domain.com/solicitorsinCOUNTY/?county=COUNTY&page=1
I haven't done much with .htaccess before so I'm not even sure if this is possible, can anyone help please? It would be much appreciated.
If you are using a rewrite rule, then put the rule for page=1 above the other rule and make sure you have the [L] flag.
Alternatively, you can use RewriteCond to prevent the rule from being run on specific URLS like this:
RewriteCond %{REQUEST_URI} !^solicitorsin([^/]+)/all/1$
RewriteRule ^solicitorsin([^/]+)/all/([0-9]+)$ /search/searchresults.php?county=$1&page=$2 [L]