Rewrite rules .htaccess file of Drupal - .htaccess

I have installed a Drupal site in www.example.com/beta
I am trying to do the following
Redirecting users to /beta when they hit www.example.com which I have achieved
RewriteBase /beta
Modify the URLs. For example www.example.com/beta/products should be modified to www.example.com/products. I just need to remove the /beta from the url.

You can do it by this code:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^beta/(.*)$ /$1 [L,NC,R]
Regards.

Related

Redirect to another domain but keep rest of URL

I have two domains in may server, a.com which is my main domain and a.fr which is my redirect domain.
I like when the user enter http://a.fr/dynamicpath/ automatically going to http://a.com/dynamicpath/, is it possible to accomplish this through htaccess?
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?a\.fr$ [NC]
RewriteRule ^ http://a.com%{REQUEST_URI} [R=301,L]

URL Rewriting on Apache Linux

Thanks in advance !! Actually i am suffring from url rewriting problem in php (apache server). Problem is :
I have to write
URL(Old)= abc.com/search_result.php?id=110 to
URL(New)= abc.com/110
it is working in opposite direction when i click the url abc.com/search_result.php?id=110 it does not change to abc.com/110
but when i click the url abc.com/110 it changes to abc.com/search_result.php?id=110
.htaccess code
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^([a-zA-Z0-9]+)$ http://www.abc.com/search_result.php?id=$1
website linnk : [ncrfloors.com][1]
Please anybody help me.....
On your old domain: Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+search_result\.php\?id=([^\s]+) [NC]
RewriteRule ^ http://abc.com/%1? [R=301,L]

htaccess Sub Dir redirect

Is there anyway for me to redirect my subdomain index to my main domain?
From Subdomain.Domain.com/index or Domain.com/SubDomainFolder/index to just Domain.com
Tried several methods from StackOverflow, but yet nothing seems to take effect. Thank you
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(?:subdomain\.)?(domain\.com)$ [NC]
RewriteRule ^(?:SubDomainFolder/|)(index)/?$ http://%1/? [L,R,NC]

How to make htaccess rule for a URL with specific characters?

I need to 301 redirect all ?print=yes URLs to the URLs without ?print=yes that contain the same name in them through .htaccess. Currently the button to PRINT is present in the header of the website so it's more than 70 URLs to fix... Removing the button to PRINT the page will ruin the design quite a bit, so it's not really an option.
I think it needs to be a RedirectMatch rule, but how do I write it?
Example: redirect 301 from domain.com/faq/?print=yes to domain.com/faq
Thanks in advance!
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^print=yes$ [NC]
RewriteRule ^ %{REQUEST_URI}? [R=301,L,NE]
I am not sure if redirect can do the same but here is how I would do it with rewrite
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\?print=yes$ $1 [NC]

url rewriting in php using .htaccess

I need to rewrite the url in my project.
I have a url like this
http://www.example.com/apps?platform=Android&category=Business&keyword=cows
and i need to rewrite this to http://www.example.com/apps/Android-Business-cows
How can i implement this url rewrite
I am cakephp framework in php.
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^(apps)/([^-]+)-([^-]+)-([^-]+)/?$ $1?platform=$2&category=$3&keyword=$4 [QSA,L,NC]
This will do (asuming you're using mod-rewrite on apache):
RewriteEngine ON
Options +FollowSymLinks -Multiviews
RewriteRule ^apps/([^-]+)-([^-]+)-([^-]+)$ apps?platform=$1&category=$2&keyword=$3

Resources