Redirect %2B to + - url

I would like to do a 301 Redirect on all %2B in URLs to +. The + in the URL is a urlencoded space. Other sites linking to mine have created %2B in the URL and a valid dynamic page is being created causing duplicate content.
For Example:
http://www.mythicalcreatureslist.com/mythical-creature/Feng%2BHwang
Should redirect to:
http://www.mythicalcreatureslist.com/mythical-creature/Feng+Hwang
I managed to do this with %20 by using this code:
Options +FollowSymlinks -MultiViews
RewriteRule ^(.+)(\s|%20)(.+)$ /$1+$3 [R=301,QSA,L,NE]
So tried this:
RewriteRule ^(.+)(\s|%2B)(.+)$ /$1+$3 [R=301,QSA,L,NE]
But that did nothing. Any help is appreciated.

The following code may help you:
RewriteEngine On
RewriteCond %{THE_REQUEST} %2B
RewriteRule ^(.+)$ %{REQUEST_URI} [R=301,L,QSA,NE]

Related

mod rewrite url automatically

I have a problem for rewrite this url:
http://example.org/public/item.php?id=4
i id like to rewrite with htaccess file in:
http://example.org/public/item/4.php
this is my htaccess file:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /public
RedirectMatch ^/$ /public/
RewriteRule ^public/item/([^/]*)\.php$ /public/item.php?id=$1 [L]
that works only if i digit manually the previous url, but i lost all the style css, javascript file, and images, also i want to do this redirect seo url automatically.
what I'm doing wrong?
You have to add a condition if the requested filename(javascript, css, image, etc. files) actually exist not to rewrite the url,
So all you have to do is to add a condition before your rewrite rule:
RewriteCond %{REQUEST_FILENAME} -f
check here the Documentation

mod_rewrite to insert directory in dynamic URLs?

I am looking for a way to write a mod_rewrite in order to insert a directory into an URL? I want to redirect old URLs to new URLs like so:
old URL: http://www.domain.com/viewtopic.php?f=1&t=128468
new URL: http://www.domain.com/forum/viewtopic.php?f=1&t=128468
I would like this to work for all values of 'f' and 't'. Thanks!
This works:
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_URI} !/forum/
RewriteCond %{REQUEST_URI} /viewtopic
RewriteRule ^viewtopic\.php$ /forum/viewtopic\.php [L,R=301]
</IfModule>
The first line checks that /forum/ is NOT already present in the URI.
The second line checks that /viewtopic is present in the URI.
the third line replaces viewtopic.php with /forum/viewtopic.php

how to convert static urls from dynamic urls?

Can you please help me this?
i have classified site: 99clix.in/latest/ , Actually it is under construction. it creates dynamic dynamics urls, i want to convert into seo friendly urls.
Eg:
DYnamic Url: http://www.99clix.in/latest/index.php?welcome/category/Mobile-Phones/Mobile-phones
Static Url:
http://www.99clix.in/latest/Mobile-Phones/Mobile-phones.
Same way i need to create for all categories and subcategory as per user search.
can you help me out for this?
Write below code in .htaccess file in your root directory, this will allow you allow you to access url without index.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Please provide little more detail about your application so we can provide more personalized solution -- are you using any framework etc..

Why any URL end with inco.in redirect to same page?

You can check this by taking any URL and append it with inco.in and enter it in search bar then you will get same page . Why and how it's happening ?
This is an image of redirected web page .
Probably,
The webpage owner inco.in use simple .htaccess redirect
RewriteEngine on
RewriteCond %{HTTP_HOST} ^inco.in [NC]
RewriteRule ^(.*)$ http://inco.in/$1 [L,R=301,NC]

HTA redirect - mask URL

I'm having trouble redirecting my main website www.mydomain.com to the folder mydomain.com/stuff/public_html/index.html while retaining www.mydomain.com in the URL. I'd prefer to use HTA over some html solution, but what's the most SE friendly and modern solution for this?
I've tried the simple HTA 301 redirect below, but it shows the file path which I want to avoid.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$
RewriteRule ^/?$ "http\:\/\/www\.mydomain\.com\/stuff\/public_html\/" [R=301,L]
Thanks!
Looks like you do not need an external redirect. You need an internal redirect. For this you need to remove the [R] flag in your rule (and have only [L]). The [R] flag forces an external redirect with a HTTP 301 response code.

Resources