I want to 301 redirect some URLs which contain "option=com_virtuemart".
I tried with this code:
RewriteCond %{QUERY_STRING} ^option=com_virtuemart
RewriteRule ^(.*)$ http://www.newsite.com/$1 [L,R=301]
But it doesn't work.
The code is working, but the server is disabled htaccess controll..
Related
How to redirect
/index.php?route=blog/blog to /blog
and
index.php?route=information/contact to /contact
The site is on Opencart 2.3.
I tried with:
RewriteRule ^index.php?route=blog/blog$ /blog [R=301,L]
I've come to the point where pages open in both ways, but don't redirect.
You can't match against query string (anything that goes after ? in URL) in pattern of a RewriteRule . You need to match against %{QUERY_STRING} variable using a RewriteCond directive
RewriteEngine On
RewriteCond %{QUERY_STRING} ^route=[^/]+/(.+)$ [NC]
RewriteRule ^ /%1? [L,R=301]
I need to redirect
www.example.com/members/?name=bla&test=dgdg
www.example.com/members/?anything=any&test=dgdg
permanently to
www.example.com/members/
within a VirtualHost configuration of Apache.
I tried
RedirectMatch ^members/\?(.*) www.example.com/members
RedirectMatch ^members/(.+) www.example.com/members
or
RewriteEngine on
RewriteRule ^/members/(.+) www.example.com/members [R=301]
But nothing seems to be working.
Thanks for your help in advance.
RewriteEngine On
RewriteCond %{QUERY_STRING} !^$
RewriteRule ^/members/ /member/ [R=301,L,QSD]
RewriteCond %{QUERY_STRING} !^$ checks whether QUERY_STRING is empty, QSD removes QUERY_STRING on redirect.
rewriting the url RewriteRule ^about/ /about.php [L,R=301] but the page is accessed via /about.php directly also. Please help to how to redirect .php file
Replace your code with this code:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+about\.php\s [NC]
RewriteRule ^ /about/ [R=302,L]
RewriteRule ^about/?$ /about.php [L,NC]
You can use this free .htaccess Redirect Generator:
http://htaccessredirect.net/
with this tool you can easily create your redirection code for .htaccess.
You can use rule to hidden redirect:
#use [L] to hidden [R] to shown redirect
RewriteRule ^(about|faq|home)/?$ $1.php [L]
#to prevent access from about.php simply do this:
RewriteRule (.+)\.php$ $1/ [R=301]
#you need to know 301 redirect will be cached with browser for long time
#so if you change rule - will be no effect for some visitors
I am new to working on a windows server and have been made aware that it is setup for ISPAI Rewrite.
I have tried creating a httpd.ini file and a .conf file with possible redirects but nothing is working.
Could someone show me how to create the correct file and then rewrite the following:
http://aspectexhibitions.co.uk/
Should redirect to:
http://www.aspectexhibitions.co.uk/
--
http://www.aspectexhibitions.co.uk/index.php
http://aspectexhibitions.co.uk/index.php
Should redirect to:
http://www.aspectexhibitions.co.uk/
Done...
[ISAPI_Rewrite]
#Redirect Non WWW to WWW
RewriteEngine on
RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]
#Redirect index.php to root
RewriteEngine on
RewriteBase /
RewriteRule ^index\.php$ http://www.aspectexhibitions.co.uk/ [NC,R=301,L]
I want to force a www. prefix on my website by using a .htaccess 301 redirect. I am currently trying:
RewriteCond %{HTTP_HOST} ^mysite.com [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]
Which normally works, but I am using Zend Framework which causes all requests to be redirected back to http://www.mysite.com/index.php regardless of the initial request.
For example...
http://mysite.com/blog,
http://mysite.com/contact,
http://mysite.com/blog/this-is-my-article,
Will all be redirected to http://www.mysite.com/index.php
However, if I initially request a specific file, such as...
http://mysite.com/some-file.htm
The redirect works properly, redirecting to http://www.mysite.com/some-file.htm
In first time, don't forget to enable the rewriting ("RewriteEngine on").
The last line is important if you use Zend Framework.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysite.com [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]
RewriteRule !\.(pdf|php|js|ico|txt|gif|jpg|png|css|rss|zip|tar\.gz)$ index.php
Now the url...
http://mysite.com/some-file.htm
... redirect to http://www.mysite.com/some-file.htm but use the index.php
Don't forget to ignore sub-domains when re-directing to www.
http://www.theblogaholic.com/2011/01/16/force-www-using-htaccess-except-for-subdomains/