htaccess redirect with question mark - apache

Hello I'm trying to redirect /fr/welterweight.php which is a local folder on my website via apache conf or .htaccess.
To http://www.bluek.com/fr/welterweight.php?c=france which is another website I own.
I tried
RewriteCond %{REQUEST_URI} /fr/welterweight.php
RewriteCond %{QUERY_STRING} ^welterweight.php$
RewriteRule ^/?$ http://www.bluek.com/fr/welterweight.php?c=france
But its not working

This rule should work from site root .htaccess:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^fr/welterweight\.php$ http://www.bluek.com/$0?c=france [L,R=302]

Related

.htaccess Messy Rewrite Rules

I could do with some assistance trying to clean up an .htaccess file that has been running on one of our servers at work.
It is currently set up so that if someone types example.com it will redirect to www.example.com. The problem is that we want to utilise subdomains but when we try to add a subdomain, like beta.example.com it will redirect to www.beta.example.com
Here is the .htaccess file
DirectoryIndex index.html index.php
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !www.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
I have tried multiple variations from questions here on SO and via Google and htaccess generators and none of them seem to help as they usually put the site in a redirect loop.
Any help on getting the configuration correct would be appreciated.
-- Chris
To automatically add a www to your domain name when there isn't a subdomain, add this to the htaccess file in your document root::RewriteEngine On
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]

redirect from not-www to www prestashop .htaccess

I have a problem with my prestashop website. For some reasons, if I put in the domain name "www.mysite.com" some modules stop working. So, I have to use "mysite.com". Problem is that I want to be displayed www.mysite.com on the browser. I know that there is set of rules to be added to .htaccess to redirect not-www to www:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
but this doesn't work with the rewritebase on prestashop's .htaccess
RewriteEngine on
RewriteRule . - [E=REWRITEBASE:/]
RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]
how can I merge the two rules?
Thank you very much
Try this default .htaccess file
Default htaccess file
and also check if mod rewrite is enable. If this is not working you can do a 301 redirection to www version.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]

.htaccess: How can I keep the redirection and remove the subdirectory path from the urls please?

I am trying to direct traffic to a subdirectory using .htaccess
The subdirectory is: /Release2/code.
The following is successfully redirecting but its is not hiding /Release2/code from the urls
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.com$
RewriteCond %{REQUEST_URI} !^/Release2/code
RewriteRule ^(.*)$ /Release2/code/$1 [L]

Redirecting Subdirectory to Subdomain with either htaccess or cpanel

I want to redirect a subdirectory to a subdomain either using .htaccess or cpanel
redirects from
domain.in/subfolder
to
subfolder.domain.in
i m using cakephp app for both domain.in and subfolder.domain.in
each have separate core library
Please help me to solve this
Thanks in advance
You can use this rule as very first rule in your /subfolder/.htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?:www\.)?domain\.in$ [NC]
RewriteRule (.*) http://subfolder.domain.in/$1 [NE,R=302,L]
Or else:
RewriteCond %{HTTP_HOST} ^(?:www\.)?(domain\.in)$ [NC]
RewriteRule (.*) http://subfolder.%1/$1 [NE,R=302,L]
Using the following .htaccess file might work:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^domain.in [NC]
RewriteRule ^(.*)$ http://www.domain.in$1 [L,R=301]
RedirectMatch 301 ^/subfolder/(.*)$ http://subfolder.domain.in/$1

.htaccess redirect request from specific domain to another domain

I have an apache server hosting a site. I have 2 domains pointing to this server, www.mysite.se and www.mysite.com.
I'm trying to figure out how to in the htaccess file to redirect traffic coming from the www.mysite.se domain to www.mysite.com/se/
I've tried several ways but cannot get it to work. I always just end up on the root of the site, as in www.mysite.com instead of the /se/ path.
This is what I've tried so far:
RewriteEngine On
RewriteCond %{http_host} ^www\.mysite\.se [NC]
RewriteRule ^(.*)$ http://www.mysite.com/se/ [R=301,NC]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?mysite.se$ [NC]
RewriteRule ^(.*)$ /se/$1
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?mysite.se$
RewriteRule ^(/)?$ se [L]
What am I doing wrong?
This seems to have finally done it!
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?mysite.se$
RewriteRule (.*)$ http://www.mysite.com/se/ [R=301,L]