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/.
Related
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 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?
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
OK, I admit ... I blow at htaccess! Therefore, I now deal with it.
I want a page like:
index.php -> localhost
index.php?group=1 -> localhost/1(/)
index.php?group=1&page=1 -> localhost/1/1(/)
So far, no problem .. However, after this I would be able to add your own GET tags.
Eg. I want the URL to be:
localhost/audi/guestbook?do=delete&id=54
Here I can not get $_GET['do'] or $ _GET['id'].
My Htaccess:
RewriteEngine on
RewriteBase /
RewriteRule ^([^/\.]+)/?$ index.php?group=$1
RewriteRule ^([^/\.]+)/?/([[a-zA-Z0-9_-]+)$ index.php?group=$1&page=$2
Grateful for sensible answer!
Add [QSA] flag to the two rewrite rules (And the [L] flag as well:
RewriteEngine on
RewriteBase /
RewriteRule ^([^/\.]+)/?$ index.php?group=$1 [L,QSA]
RewriteRule ^([^/\.]+)/?/([[a-zA-Z0-9_-]+)$ index.php?group=$1&page=$2 [L,QSA]
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.