Redirect %20%E2%80%8E - apache

I have this customer that send an email with http://url/%20%E2%80%8E and everyone is getting a 404 not found. So he asked me for a redirection and I though sure easy. But it looks like is not working... please help!!
I tried this:
redirect 301 /\%20\%E2\%80\%8E http://url/promo-content/
and
redirect 301 /%20%E2%80%8E http://url/promo-content/
and is not working..
I also tried this
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/([a-zA-Z0-9_-]+)/\%20\%E2\%80\%8E$
RewriteRule ^(.*) http://url/promo-content/%1/ [R,L]
But still not working... any sugestion???

The URI gets decoded first before mod_rewrite rules are applied. Try:
RewriteEngine On
RewriteRule ^\ ‎ /promo-content/ [L,R=301]

Related

.htaccess redirect to subdomain url with hash

I'm trying to redirect a site with the following url structure:
https://example.com/2021/about
to
https://2021.example.com/#about
https://example.com/2021/visit
to
https://2021.example.com/#visit
how can i do this?
i tried adding this to the /about directory in the original domain:
RewriteEngine on
RewriteBase /
RewriteRule (.*) https://2021.example.com/#about [R=301,NE, L]
but what i got after the redirect was
https://2021.example.com/#about2021/about
which is not right. any help is appreciated
[EDIT] i only want to apply this to some folders, like /2021/about and 2021/visit
You may use this redirect rule:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?:www\.)?(example\.com) [NC]
RewriteRule ^(20\d{2})/(.+?)/?$ https://$1.%1/#$2 [R=301,L,NE]
Make sure this is your topmost rule in .htaccess and you clear your browser cache before testing this new rule.
Could you please try following, written based on your shown samples. Please make sure to clear your browser cache before testing your URLs. Following will only be applied to 2021/about OR 2021/visit uris.
RewriteEngine ON
RewriteCond %{HTTP_HOST} (example\.com) [NC]
RewriteRule ^(2021)/(about|visit)/?$ http://$1.%1/#$2 [R=301,NC,NE,L]

301 redirection in htaccess not working

I have and issue when I'm trying to redirect my old domain to my new domain. Things look like that right now:
newdomain.pl <- is connected to blogger account
olddomain.pl <- is connected to server with .htaccess file (before it was connected to blogger account)
I would like it to work like that : olddomain.pl/subdomain -> redirect to newdomain.pl/subdomain. But whatever I try to put into my .htaccess file it's redirecting my old site to main page of newdomain (newdomain.pl). I've tried codess like that:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^newdomain.pl[nc]
RewriteRule ^(.*)$ http://www.newdomain.pl/$1 [r=301,nc]
but it's also redirecting to main page of new domain. Only when I put:
RedirectRule / http://www.newdomain.pl
It's redirecting to http://www.newdomain.plsubdomain <- but there is slash "/" missing between the newdomain name and subdomain. Unfortunately when I write this:
RedirectRule / http://www.newdomain.pl/
it's redirecting to main domain page http://www.newdomain.pl, so it's not working. I don't know what can be wrong, I'm fighting with that three days already. Does anyone have an idea where can be the problem? Maybe there is something wrong with hosting that I bought? Thank you in advance for any response
Regards, Pawel
Try next:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com$
RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R]
For only redirecting queries without direct redirecting to domain remove R flag.
Try this in olddomain/.htaccess :
RedirectMatch ^/(.*)$ http://newdomain.com/$1
Ok I found a solution. The problem was not including "www" in RewriteRule. When I changed it, it worked. I'm putting the code that worked for me below:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.olddomain.pl$
RewriteRule ^(.*)$ http://www.newdomain.pl/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^olddomain.pl$
RewriteRule ^(.*)$ http://www.newdomain.pl/$1 [L,R=301]
Thank you everyone!

Where is my mod rewrite fail?

I have got url
ipaddr/opensys/base/
and some other similar, like
ipaddr/opensys/base/something.php?olol=yep
I want to remove from url "opensys" and display there "center", i want to see this links working:
ipaddr/center/base/
and
ipaddr/center/base/something.php?olol=yep
I did it with symlinks, but it was not good, because system is very difficult and with symlink some plugins not works, I want to do it with .htaccess only, after it all will be ok.
My htaccess is:
but links, which i want to see is not working, why?
RewriteEngine on
RewriteRule ^/opensys/base/(.*)$ /center/base/$1 [L]
RedirectMatch 301 ^/opensys/base/(.*)$ /center/base/$1
Redirect works good, but i see 404, rewrite rules is not working. Why?
You also need to handle the /center/base/ now in the .htaccess file as you must be handling opensys earlier. Something like this -
RewriteRule ^/opensys/base/(.*)$ /center/base/$1 [R=301]
RewriteRule ^/center/base/(.*)$ /index.php?args=$1 [QSA,L]
You can use this code in root .htaccess:
RewriteEngine on
RewriteCond %{THE_REQUEST} /opensys/(base/\S*)\s [NC]
RewriteRule ^ /center/%1 [R=301,L,NE]
RewriteRule ^center/(base/.*)$ opensys/$1 [L,NC]

301 .htacess redirect issue

I'm making a website, (for examples sake it will be http://www.example.com).I am trying to make it redirect http://example.com/jquery/releasenotes to http://blog.jquery.com/?s=release+notesBy using this it put a / on the end, this stops it from working, since it searches for the / aswell. I tried using http://goo.gl and converted it to http://goo.gl/WdiItL Somehow this also fails to remove the / when in redirect. However if you simply go to http://goo.gl/WdiItL it works. My .htaccess file looks like this:
Redirect 301 /jquery/releasenotes http://goo.gl/WdiItL
I have no idea how to make it not have the / on the end.Any help would be hugely appreciated!
Use this RedirectMatch rule:
RedirectMatch 301 ^/jquery/releasenotes/?$ http://goo.gl/WdiItL
Make sure to clear your browser cache before testing this
I think you have to use mod_rewrite's %{QUERY_STRING}
for example:
RewriteCond %{HTTP_HOST} =example.com [NC]
RewriteCond %{QUERY_STRING} ^(par1=1&par2=2)
RewriteRule ^$ http://alt.example.com/?%1 [R=301,L]

.htaccess redirect except one subfolder

I need following type redirection:
/store/something/namestore to /store/namestore
However there is one exception:
/store/namestore/page/2 should not redirect to anything.
/store/namestore/page/3 should not redirect to anything. and so on.
If i understud the question right, this should be the solution.
RewriteEngine on
RewriteRule ^/store/([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)$ /store/$2/ [R]
or
RewriteEngine on
RewriteRule ^/store/([^/]+)/([^/]+)$ /store/$2/ [R]
Here is the solution in case someone else need:
RewriteCond %{REQUEST_URI} !^/stores/(.+)/page/.*$
RewriteRule stores/(.+)/(.+) stores/$2 [R=301,L]