Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I want to redirect old internal page to my home page. My .htacess file starts like this:
RewriteEngine On
RewriteBase /
Redirect 301 /int/index.php?m=help https://website.com
Further down I have more rules to force SSL and no "www" and these rules are working fine, but for some reason Redirect directive is being ignored, client can open the page without being redirected.
I suspect it's due to the ?m=help. I would use a RewriteRule like this instead:
RewriteCond %{QUERY_STRING} m=help
RewriteRule index\.php https://website.com? [R=301,L]
Please note:
the ? at the end of the rewritten path is needed to cut off the ?m=help; if you omit it, you'll redirect to https://website.com?m=help
the [R=301,L] means: "redirect to the page" and (L) "stop the rewrite engine after applying this rule", that is, no additional rewriting will be appied to the string https://website.com?
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
How can I set individual URLs via 301 redirect in the htaccess and redirect all other URLs that do not have a 301 to the home page?
Well, you simply implement one 301 redirection per URL you want to get redirected. Then below you implement a single catch all rule to rewrite or redirect everything else to whatever you consider your "home page". So first the exceptions, then the general rule:
RewriteEngine on
RewriteRule ^/?path/one https://example.com/path/A [R=301,L]
RewriteRule ^/?path/two https://example.com/path/B [R=301,L]
RewriteRule ^/?path/tre https://example.com/path/C [R=301,L]
RewriteRule ^ /index.php [END]
Of course this is only a rough pointer into the right direction, you have to adapt it to your specific situation we do not know.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I've set up a bit.ly link and printed it on 1000 flyers.
Somehow the bit.ly target link contains some strings which shouldn't be there (https://example.com/page/%E2%80%8E instead of https://example.com/page/)
Can I get rid of this string using rewrite rules in .htaccess?
Any help is appreciated!
When you just accidentally added the string %20%E2%80%8E in the creation of the short link, then you can just get another short link without accidentally added the string again.
Anyway, I think these .htaccess directives are what you want:
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/([a-zA-Z0-9_-]+)\%20\%E2\%80\%8E$
RewriteRule ^(.*) https://example.com/%1 [R,L]
It will redirect example.com/$anything%20%E2%80%8E into example.com/$anything
Just make sure that there's Apache HTTP Server with mod_rewrite on your web hosting account. And considered this link about the [R=301] flag: https://stackoverflow.com/a/15999177/2007055.
This code:
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/([a-zA-Z0-9_-]+)/\%20\%E2\%80\%8E$
RewriteRule ^(.*) https://example.com/%1/ [R,L]
Is to redirect example.com/$anything/%20%E2%80%8E into example.com/$anything/.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
i want to redirect page url using .htaccess [R=301]
original url : http://www.encros.fr/la-boutique-encros/recharge-toner
redirect url : http://www.encros.fr/recharge-toner
anybody can help me ?
You need something like this in your .htaccess file:
RewriteEngine on
RewriteRule ^/la-boutique-encros/recharge-toner$ /recharge-toner [R=301,L]
The [R=301] flag sets the return code. The [L] flag prevents other rules from being applied to this specific rewrite.
References:
About rewrite: http://httpd.apache.org/docs/2.4/rewrite/remapping.html
About the rewrite flags: http://httpd.apache.org/docs/2.4/rewrite/flags.html
Try this
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^recharge-toner$ /la-boutique-encros/recharge-toner [L]
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have some simple redirects in my htaccess file. However, the domain is going to change...I was hoping I could write something that gets the domain name?
Someone suggested:
http://%{HTTP_HOST}/
but this doesn't work.
If you want to keep the old domain and redirect all the requests to the new one, may this instruction be helpful:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^old-domain.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.old-domain.com$ [NC]
RewriteRule ^(.*)$ http://www.new-domain.com/$1 [L,R=301]
Put the code above in a .htaccess file at the root of old-domain.
But if you are NOT worried about the old url addresses or search engines crawled your old pages, you won't need to do that, just move all your data (including .htaccess file) to your new domain
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have a problem redirecting a folder to another one.
The rule seems to "work" but it stumble at some point adding some other stuff.
Here an example:
The goal is to redirect traffic from oldfolder (not existing anymore) to newfolder.
www.domain.com/one/oldfolder/year/ --> www.domain.com/one/newfolder/year/
So i set up the following rules (first one for the canonical url):
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com$
RewriteRule ^/?$ "http\:\/\/www\.domain\.com" [R=301,L]
RewriteRule ^(.*)/oldfolder/(.*)$ $1/newfolder/$2 [R=301,L]
The problem is that it redirects to:
http://www.domain.com/home/username/public_html/www.domain.com/one/newfolder/year/
Anyone can spot the problem in the rule i wrote?
Thank you very much for your help.
Check your DocumentRoot
Check the Directory directive
Make sure you have RewriteBase / if this .htaccess file is in your document root.