1- I wrote the following redirect expecting that when this url
"http://www.curtainrodstore.com/index.php?crn=234"
was entered it would redirect to
"http://www.curtainrodstore.com/product-category/curtains-drapery/shower-curtains/"
2- Instead it redirects to
"http://www.curtainrodstore.com/?crn=243"
3- Note the missing
"index.php"
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^curtainrodstore.com [NC]
RewriteCond %{REQUEST_FILENAME} index\.php
RewriteCond %{QUERY_STRING} crn=243
RewriteRule ^.*$ http://www.curtainrodstore.com/product-category/curtains-drapery/shower-curtains/ [R=301,L]
</IfModule mod>
Does anyone have any suggestions as to why it is not working?
Here is an updated attempt list…
<IfModule mod_rewrite.c>
RewriteEngine On
#ATTEMPT 1
#RewriteCond %{HTTP_HOST} ^curtainrodstore.com [NC]
#RewriteCond %{REQUEST_FILENAME} index\.php
#RewriteCond %{QUERY_STRING} crn=243
#RewriteRule ^.*$ http://www.curtainrodstore.com/product-category/curtains-drapery/shower-curtains/ [R=301,L]
#ATTEMPT 2
#RewriteRule ^index\.php\?crn=243$ http://curtainrodstore.com/product-category/curtains-drapery/shower-curtains/ [R=301,L]
#ATTEMPT 3
#RewriteCond %{HTTP_HOST} ^www.curtainrodstore.com$ [NC]
#RewriteCond %{QUERY_STRING} ^crn=234$
#RewriteRule ^index\.php$ http://www.curtainrodstore.com/product-category/curtains-drapery/shower-curtains/? [R=301,L]
#ATTEMPT 4
#RewriteCond %{HTTP_HOST} ^curtainrodstore.com$ [NC]
#RewriteCond %{QUERY_STRING} ^crn=234$
#RewriteRule ^index\.php$ http://curtainrodstore.com/product-category/curtains-drapery/shower-curtains/? [R=301,L]
#ATTEMPT 5
#
</IfModule>
You may try this:
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?curtainrodstore.com [NC]
RewriteCond %{REQUEST_URI} index\.php [NC]
RewriteCond %{QUERY_STRING} crn=234 [NC]
RewriteRule .* product-category/curtains-drapery/shower-curtains/? [R=301,L]
Redirects permanently
http://www.curtainrodstore.com/index.php?crn=234
To:
http://www.curtainrodstore.com/product-category/curtains-drapery/shower-curtains/
For silent mapping, remove R=301 from [R=301,L]
Make sure browser's cache is cleared before any test
Related
OK, so I'm trying to do this:
!www -> www
http -> https
EXCEPT
/[a-f0-9]{11}/
https://www.domain.com/[a-f0-9]{11}/ -> http://www.domain.com/[a-f0-9]{11}/
map to controller: index.php?(uri)
e.g. /controller/action/id -> index.php/controller/action/id
Summary: all URLs should be https://www.domain.com/(.*) except /[a-f0-9]{11}/, which should be forced to http only.
I have an old set of rules (see below) which don't look very clean.
I've tried adding to them to account for /[a-f0-9]{11} and it ends up redirecting instead of remapping, so I end up with www.domain.com/index.php/thepattern0
How do I clean these rules up and make this work?
<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews -Indexes
RewriteEngine On
RewriteBase /
#redirect to www
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301]
#redirect to https
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#hide index.php
RedirectMatch 404 .*php\.ini
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ index.php/$1 [L,QSA]
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
You can use:
Options +FollowSymLinks -MultiViews -Indexes
RewriteEngine On
RewriteBase /
#redirect to www
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#redirect to https
RewriteCond %{HTTPS} off
RewriteCond %{THE_REQUEST} !\s/+[a-f0-9]{11}[/?\s] [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NC]
#redirect to http
RewriteCond %{HTTPS} on
RewriteCond %{THE_REQUEST} \s/+[a-f0-9]{11}[/?\s] [NC]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NC]
#hide index.php
RewriteRule \.(?:php|ini)$ [L,R=404,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
I have the following htaccess file. I do not want to perform a redirect from https to http on a certain file. how can i achieve this?
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.spectrumasa.com$ [NC]
RewriteRule ^(.*)$ http://www.spectrumgeo.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^intranet.spectrumasa.com$ [NC]
RewriteRule ^(.*)$ http://www.spectrumgeo.com/ [R=302,L]
RewriteCond %{HTTP_HOST} ^www.asb.com.au$ [NC]
RewriteRule ^(.*)$ http://www.spectrumgeo.com/ [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.spectrum-geopex\.com\.eg$ [NC]
RewriteRule ^(.*)$ http://www.spectrumgeo.com/spectrum-geopex [R=301,L]
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/server-status
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I would like to access only the following through https http://www.spectrumgeo.com/wp-content/uploads/Spectrum_logo_email-171w.jpg
Add a condition to your rule:
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/wp-content/uploads/Spectrum_logo_email-171w\.jpg$
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
You can have something complex in picking with to redirect to https:// from http:// but you can accomplish a simple redirect on a single file via this method.
RewriteEngine
Redirect http://www.spectrumgeo.com/wp-content/uploads/Spectrum_logo_email-171w.jpg https://www.spectrumgeo.com/wp-content/uploads/Spectrum_logo_email-171w.jpg
This will solve accessing only the above url you have through https://
I want redirect this urls:
http://tops.domain.com/test
http://files.domain.com/css/style.css
http://domain.com/test
to these:
/tops.php?what=test
/css/style.css
/index.php?username=test
I written this codes in .htaccess file and put it in root:
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^tops\. [NC]
RewriteRule .* tops.php?what=$0 [QSA,L,NC]
RewriteCond %{HTTP_HOST} ^files\. [NC]
RewriteRule .* $0 [NC,L,QSA]
RewriteRule .+ index.php?username=$0 [L,QSA]
but not work right
Use this .htaccess :
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^files\. [NC]
RewriteRule ^ - [L]
RewriteCond %{HTTP_HOST} ^tops\. [NC]
RewriteCond %{REQUEST_URI} !^/tops\.php [NC]
RewriteRule .* tops.php?what=$0 [QSA,L,NC]
RewriteCond %{QUERY_STRING} !^username= [NC]
RewriteRule .+ index.php?username=$0 [L,QSA]
Currently my site can only be visited when visiting www.mysite.net or http://www.mysite.net. How can I change this so that when one just visits http://mysite.net, that you will be directed to www.mysite.net?
Here is my current HTACCESS file content
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I also tried this...
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %mysite.net !^www\.
RewriteRule (.*)$ http://www.%mysite.net/$1 [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Thank You
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
edit:
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
edit 2
Add URL Rewrite Rule To Wordpress this is not helpful?
You Must Use This Code In htaccess File To Preferred www Version:
RewriteCond %{HTTP_HOST} !^(.).YourDomain.com$ [NC] RewriteRule ^(.)$ http://www.YourDomain.com/$1 [R=301,L]
The following code in the .htaccess file is supposed to, among others I guess, redirect the secondary domains towards the main domain:
<ifModule mod_headers.c>
Header unset Last-Modified
</ifModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
RewriteCond %{HTTP_HOST} ^secondaryDomain1.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.secondaryDomain1.com$
RewriteRule ^/?$ "http\:\/\/mainDomain\.com\/" [R=301,L]
RewriteCond %{HTTP_HOST} ^secondaryDomain2.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.secondaryDomain2.com$
RewriteRule ^/?$ "http\:\/\/mainDomain\.com\/" [R=301,L]
RewriteCond %{HTTP_HOST} ^secondaryDomain3.com$ [OR]
RewriteCond %{HTTP_HOST} ^secondaryDomain3.com$
RewriteRule ^/?$ "http\:\/\/mainDomain\.com\/" [R=301,L]
RewriteCond %{HTTP_HOST} ^secondaryDomain4.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.secondaryDomain4.com$
RewriteRule ^/?$ "http\:\/\/mainDomain\.com\/" [R=301,L]
RewriteCond %{HTTP_HOST} ^secondaryDomain5.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.secondaryDomain5.com$
RewriteRule ^/?$ "http\:\/\/mainDomain\.com\/" [R=301,L]
RewriteCond %{HTTP_HOST} ^secondaryDomain6.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.secondaryDomain6.com$
RewriteRule ^/?$ "http\:\/\/mainDomain\.com\/" [R=301,L]
RewriteCond %{HTTP_HOST} ^secondaryDomain7.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.secondaryDomain7.com$
RewriteRule ^/?$ "http\:\/\/mainDomain\.com\/" [R=301,L]
Unfortunately if I type www.secondaryDomain.com/index.html or www.secondaryDomain.com/directory it is not redirected towards the main domain.
What has been done wrong in the .htacess file?
RewriteRule ^/?$ "http\:\/\/mainDomain\.com\/" [R=301,L]
This rewrites only URLs ending in / or nothing at all. You should use something like:
RewriteRule (.*) "http\:\/\/mainDomain\.com$1" [R=301,L,QSA]
Which redirects and preserves all path-info.
Try this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)$ http://mainDomain.com/ [L]
</IfModule>
I am assuming that this .htaccess file is for secondarydomain.com ...