I have idx feeds from idxbroker.com, but the url the provide is not such a clean url.
http://myrealestatewebsite.idxbroker.com/i/xxxx-xxxxx-xxxxx-xxx
Is there a way to change the url with htacess, so
when visitor type http://www.myrealestatewebsite.com/xxxx-xxxxx-xxxxx-xxx
is shows content of http://myrealestatewebsite.idxbroker.com/i/xxxx-xxxxx-xxxxx-xxx
Do i have to change my links also? a way that will benefit SEO as all are hosted in the main website http://www.myrealestatewebsite.com
Yes, try this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteCond %{THE_REQUEST} /i/([^\s]+) [NC]
RewriteRule ^ /%1 [R=301,L]
RewriteCond %{REQUEST_URI} !/i/ [NC]
RewriteRule ^(.+)$ /i/$1 [L]
Once that is there you can change your links to without /i/ at front. However till the time you don't change first 301 rule will take care of it.
Related
I want to Use dropbox download links with my custom domain.
example: dropbox file download URL - https://www.dropbox.com/s/ABCD/filename?dl=1
It's returning direct download that's fine. I want to do with https://mydomain/s/ABCD/filename?dl=1. Where ABCD will be dynamic.
Is This Possible?
EDIT: In case you want to hit URL http://yourdomain/s/filename/dl=1(as per samples only) and which should be served by backend url http://dropbox then try following.
RewriteEngine ON
RewriteCond %{HTTP_HOST} ^(?:www\.)mydomain(?:\.com)?$ [NC]
RewriteCond %{REQUEST_URI} ^/s/[\w-]+/?$ [NC]
RewriteCond %{QUERY_STRING} ^dl=1 [NC]
RewriteRule ^(.*)$ https://www.dropbox.com%{REQUEST_URI} [NE,QSA,L]
This assumes that we want to hit http://dropbox.com/ which should be served by http://yourdomain/ Based on your shown samples, could you please try following. Please make sure you clear your browser cache before testing these URLs.
RewriteEngine ON
RewriteCond %{HTTP_HOST} ^(?:www\.)dropbox\.com [NC]
RewriteRule ^(.*)$ https://mydomain%{REQUEST_URI} [NE,QSA,L]
I have a full site setup at mysite.com/2/
I want urls like:
mysite.com/about to redirect to mysite.com/2/about
mysite.com/work/photos to redirect to mysite.com/2/work/photos
I was hoping I could solve this and add the /2 after the domain through the htaccess file and not have to move the whole site up a level.
Try the folowing code if you want redirect
RewriteEngine On
RewriteCond %{REQUEST_URI} !(about|work/photos)/(2)
RewriteRule ^(about|work/photos)/(.*)$ /$1/2/$2 [R=301,L]
If you need only internal redirection change the last line with this :
RewriteRule ^(about|work/photos)/(.*)$ /$1/2/$2 [L]
If you want to change all requests :
RewriteEngine On
RewriteCond %{REQUEST_URI} !/(2)
RewriteRule ^(.*)/(.*)$ /$1/2/$2 [R=301,L]
I have a domain
http://www.example.biz/
I developed a site and put the code in a sub folder on this domain for example, the site is at
http://www.example.biz/site
now, I wanted to point my main domain to this folder so that when user visits example.biz he actually sees example.biz/site and for that, I added the below lines in .htaccess
RedirectMatch ^/$ /site/
it works perfectly however, the url user sees is
http://www.example.biz/site
I do not want that, I wanted user to only see http://www.example.biz as URL but this domain should point to the sub folder invisibly. How should I do that ?
Using mod_rewrite you can use the below rule, now when you access http://www.example.biz it will show the index file from for site/.
RewriteEngine On
RewriteRule ^$ /site/ [L]
Or if you want to show every file try with below,
RewriteEngine On
RewriteRule ^(/|.+)$ site/$1 [L]
I found a simpler solution,
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [NE,R=301,L]
RewriteCond %{HTTP_HOST} ^(www\.)?example\.biz$
RewriteRule !^site/ /site%{REQUEST_URI} [L]
Hi I have many URL's from an old site like below:
news_article.asp?id=51
I want to send ALL urls no matter what the ID value to /news/
I have tried to the below but I get /news/?id=51
RewriteCond %{QUERY_STRING} ^id=51$
RewriteRule ^news_article.php /news? [NC,R,L]
Thanks!
You can use this rule as the very first rule in your site root .htaccess:
RewriteCond %{QUERY_STRING} (?:^|&)id=\d+(?:&|$) [NC]
RewriteRule ^news_article\.php$ /news/? [NC,R=302,L]
I'm running a wordpress installation and want to move specific feeds off-site. I've already got most of the technology down, but here's the problem. I want the following URL:
http://www.csicon.net/g/feed
to redirect to
http://feed.mesr.it/g
But if the URL comes in like this:
http://www.csicon.net/g/feed?noRedirect
I don't want it to redirect but load the original. Any thoughts?
The .htaccess file on http://www.csicon.net/ would contain:
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^\/g\/feed$ http://feed.mesr.it/g [L,R=301]
Note: It has not been tested, but you get the idea.
Later Edit: Also, this can be done in PHP.
You can use this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)csicon\.net$ [NC]
RewriteCond %{QUERY_STRING} !(^|&)noRedirect [NC]
RewriteRule ^([^/]+)/feed/?$ http://feed.mesr.it/$1 [L,NC,R=302]