I want to redirect all requests to http://www.example.com/category/* to http://www.example.com.
This is what I tried:
RewriteRule http://www.example.com/category/.* http://www.example.com [R=301,L]
Unfortunately, this does not work. Any ideas how to write the rule correctly?
Thanks!
You can use:
RewriteEngine on
RewriteRule ^category/ /? [NC,R=301,L]
Please try below thing.
RewriteEngine on
RewriteRule "http://www.example.com/category/.*" "http://www.example.com" [PT]
Related
I have read about htaccess redirect and rewrite on stackoverflow and on other sites and learned how to redirect simple pages and directories, but there are about 30 links remaining that I haven't been able to redirect. The reason appears to be because they contain "?" in the link's URL. I've tried the solutions posted but I haven't been able to make enough sense of them to succeed.
These work:
Redirect /Corpfleet.php htp://www.marketyourcar.cm/wraps.php
Redirect /drivers.php htp://www.marketyourcar.cm/drivers.php
Redirect /galleries.php htp://www.marketyourcar.cm/galleries.php
These do NOT work:
Redirect /ad.php?View=FAQ htp://www.marketyourcar.cm/advertiser-faqs.php
Redirect /ad.php?View=gallery htp://www.marketyourcar.cm/galleries.php
Redirect /ad.php?View=Materials htp://www.marketyourcar.cm/products-services.php
Yes, I know that the URL above is htp and .cm - I had to break it in order to make this post with my low reputation level.
If anyone can help with this I'd appreciate it.
Thanks
If you want to redirect from like:
site.com/index.php?blabla=1&id=32
to
site.com/contact.html
then use:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} blabla=1&id=32
RewriteRule ^(.*)$ http://www.site.com/contact.html? [R=301,L]
</IfModule>
Redirect can't handle that. RewriteRule can. This should work.
RewriteEngine on
RewriteRule ^/ad\.php\?View\=FAQ$ http://www.marketyourcar.cm/advertiser-faqs.php [R=301,L]
RewriteRule ^/ad\.php\?View\=gallery$ http://www.marketyourcar.cm/galleries.php [R=301,L]
RewriteRule ^/ad\.php\?View\=Materials$ http://www.marketyourcar.cm/products-services.php [R=301,L]
Or try this:
RewriteEngine on
RewriteRule ^/ad.php?View=FAQ$ http://www.marketyourcar.cm/advertiser-faqs.php [R=301,L]
RewriteRule ^/ad.php?View=gallery$ http://www.marketyourcar.cm/galleries.php [R=301,L]
RewriteRule ^/ad.php?View=Materials$ http://www.marketyourcar.cm/products-services.php [R=301,L]
This might work:
Example:
RewriteEngine On
RewriteRule ^/ad.php?View=FAQ$ http://www.marketyourcar.cm/advertiser-faqs.php? [R=301,L]
Add a trailing ? to the substitution URL to remove the incoming query.
Is it possible to redirect based on an url that would be as:
www.url.com/stuff.php
But not redirect if the url contained any characters after the php, as such:
www.url.com/stuff.php?variables=values&othervariable=othervalue&etc=more
I have no clue how to wriite this either.
Thanks in advance!
Edit: basically I need the redirect to happen to www.url2.com only if www.url.com ends with .php, but not if the .php is followed by variables.
try
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^/site.com/?$ /site.com/cart.php [R=301,NC,L]
Try:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^/?cart.php$ / [L,R=301]
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^stuff.php$ RELATIVE_OR_ABSOLUTE_URL_HERE [L]
I've having a bit of trouble figuring out how to mass redirect a lot of files.
http://www.mysite.com/verify.php?site=mydomain.com
to
http://www.mysite.com/verify/mysite.com
And of course "mysite.com" will always be a different domain so that should be dynamic.
This is the code that I was using:
RedirectMatch 301 ^/verify\.php\?site=([a-zA-Z0-9\.\-]+)$ /verify/$1
Can someone please post what I need to change to make this work or a correct version of my code above? Thanks for your time!
Try this:
EDIT:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^verify/(.*)$ verify.php?site=$1 [L]
Then try to load this in browser:
http://www.mysite.com/verify/mysite.com
Try one of the following:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /verify\.php\?site=([^&\ ]+)
RewriteRule ^ /verify/%1 [L,R=301]
Or
RewriteEngine On
RewriteCond %{QUERY_STRING} ^site=([^&]+)
RewriteRule ^/?verify\.php$ /verify/%1 [L,R=301]
I have the following URL structures for my website:
http://domain.com/slug/1/test-test.html
http://domain.com/slug/2/test-test.html
and i want to change it to
http://domain.com/new-1-test-test.html
http://domain.com/new-2-test-test.html
i have already tried
RewriteRule ^slug$ /new- [R=301,L]
RewriteRule ^/?my\slug /new [R=301,L]
but it does't work..
anyone know how to redirect this with htaccess?
Thanks
Try this - RewriteRule ^slug/([0-9]+)/(.*)$ /new-$1-$2 [R=301, L]
RewriteEngine On
RewriteRule ^slug/([0-9])/(.*)$ /new-$1-$2 [R-301,L]
I want to
redirect http://www.mysite.com/index.php?option=com_content&view=frontpage&Itemid=1
TO
http://www.mysite.com/
Can you please show me the 301 redirect rule for htaccess?
Thanks.
I tried the following, but no luck.
RewriteCond %{QUERY_STRING} ^option=com_content&view=frontpage&Itemid=1$
RewriteRule ^/index.php$ http://www.mysite.com [L,R=301]
You can try below configuration,
RewriteCond %{QUERY_STRING} option=com_content&view=frontpage&Itemid=1
RewriteRule index\.php$ /? [L,R=301]
I tried it on my domain and it works fine. Hope this works for you too... :)
According to www.htaccessredirect.net, the code to do this would be:
Redirect 301 /index.php?option=com_content&view=frontpage&Itemid=1 /
Alternatively, you could look in to using apache's mod_rewrite module.