I have a site created specific for mobiles. I added the code below into my htaccess for a redirect but it does not seem to work.
Can anyone enlighten me please
#custom redirects
RewriteEngine on
Redirect 301 /cartypes.php?cartype=12 http://m.cartypecompany.com/redcars.php
#end custom redirects
Redirect directive is not used with mod_rewrite's RewriteEngine On and you need a RewriteCond to match query string. Use this rule:
RewriteEngine on
RewriteCond %{HTTP_HOST} =m.cartypecompany.com
RewriteRule ^redcars\.php$ /cartypes.php?cartype=12 [L,NC,QSA]
Related
Having checked other questions and trying the suggested solutions, nothing has worked so far.
I'm trying to redirect certain URLs from the old-domain to URLs on the new-domain, not necessarily with the same page names. The rest of the URLs should be redirected to the root of the new-domain. This is what I've tried. The redirecting of all pages to the root of the new-domain works, just not the individual pages:
RewriteEngine on
Redirect 301 /travel/ferry.html http://www.new-domain.com/ferry/
RewriteEngine off
#
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?old-domain\.com$ [NC]
RewriteRule ^ http://www.new-domain.com/? [R=301,L]
Thank you.
Don't mix Redirect directive and RewriteRule directives as they come from different Apache modules and their order of execution might be unpredictable.
You may have your rules as this:
RewriteEngine on
# keep specific redirect here
RewriteRule ^travel/ferry\.html$ http://www.new-domain.com/ferry/ [L,NC,R=301]
# redirect rest of the URLs to root
RewriteCond %{HTTP_HOST} ^(?:www\.)?old-domain\.com$ [NC]
RewriteRule ^ http://www.new-domain.com/? [R=301,L]
Make sure to test it in a new browser or test after fully clearing browser cache.
I want to redirect the user to other link only if the complete url matches and also is it possible that after redirection the url remains same as that of the old one from where user is redirected
I am writing the following rule
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !http://bestcenters.net/services$ [NC]
RewriteRule ^(.*)$ https://4677--586.rocketquotes.com/franchise [L,R=301]
Yes i have solved the issue. You just have to 301 redirect the new rule will looks like this
Redirect 301 ^/old-page.html$ http://newdomain/
This is the rule that helped me achieve what I wanted.
I'm trying to create a URL redirect but so far everything I have tried just hasn't shown any effect on the site. I know ModRewrite is enabled as there are other rewrites taking place. The whole purpose of this is to handle old URLs from the former version of the website.
What I want to achieve is a redirect of a URL with the following format:
/resources/view?id={id} and redirect it to /resources/{id}.
I've been trying to do so with variants of this:
RewriteRule ^resources/view?id=([0-9+])$ /resources/$1 [R=301,L]
and also this:
RewriteCond %{QUERY_STRING} ^id=([0-9]*)$
RewriteRule ^/resources/view$ /resources/$1? [R=301,L]
Cheers.
You can use these 2 rules in your site root .htaccess:
Options -MultiViews
RewriteEngine On
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} /resources/view\?id=(\d+) [NC]
RewriteRule ^ /resources/%1? [R=301,L,NE]
# internal forward from pretty URL to actual one
RewriteRule ^resources/(\d+)/?$ resources/view?id=$1 [L,QSA,NC]
I need some help trying to redirect a query to a url.
www.example.com/?categoryID=79
needs to redirect to
www.example.com/catname
where catname is just a string, it has no variables.
Here's what I tried so far:
I began with a humble approach that failed horribly:
redirect 301 /?CategoryID=79 http://www.example.com/catname/
then i moved on to mod_rewrite :
RewriteCond %{QUERY_STRING} CategoryID=79$
RewriteRule (.*) /catname/? [R=301,L]
Both did not work and I'm actually stomped.
any help would be appreciated.
Just to be clear, In the end i'll have many of these rules redirecting to various category names.
important - it's not enough for /catname to display the proper page, the request with the query parameter must redirect to the new url.
This rule should work for you as first rule in your .htaccess:
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+\?CategoryID=79[&\s] [NC]
RewriteRule ^ /catname/? [R=302,L]
I have trouble getting this to work properly, what I'm trying to do is make
http://subdomain.domain.com redirect to domain.com:8080 while keeping the original url
"subdomain.domain.com"
Code so far:
RewriteEngine on
RewriteCond %{HTTP_HOST} subdomain.domain.com
RewriteRule ^(.*)$ http://%1domain.com:8080$1 [L]
Which does the redirect, but browser url changes to "http://domain.com:8080" which is not what I seek.
Thank you in advance!
For this to happen you need to enable mod_proxy in subdomain\.domain\.com. Once it is enabled try this rule in DocumentRoot/.htaccess of subdomain.domain.com:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^subdomain\.(domain\.com)$
RewriteRule ^ http://%1:8080%{REQUEST_URI} [L,NE,P]