RewriteRule accepts only HTTPS but not HTTP - .htaccess

I have this URL: https://example.com/folder/cr/other/1234/orders.php
and have this in my .htaccess file (inside https://example.com/folder/):
# Turn on the rewriting engine
RewriteEngine On
# Rewrite for cronjobs
RewriteRule ^cr/([^/]*)/([^/]*)/orders\.php$ index.php?module=$1&action=x&id=$2&s=ord [L]
This HTTPS url works but when I try with HTTP it doesn't work but redirects to a 404 not found page.
So what I am missing in the rewrite rule?

Related

htaccess redirect some partical url 301 SEO

something on our BLOG URLS have changed.
No i want to have some URL path deleted in urls.
Example:
OLD URL:
https://do-main.de/blog/entry/die-xxx-der-portrait
NEW URL:
https://do-main.de/blog/die-xxx-der-portrait
My htaccess attempt to setup:
#OLD BLOG URLS
RewriteEngine On
# anything that is equal to https://do-main.de/blog/entry/*
RewriteCond %{HTTP_HOST} ^do\-main\.de\/blog\/entry\/$
# redirects to https://do-main.de/blog/*
RewriteRule ^/?(.*)$ https://do-main.de/blog/$1 [R=301,L]
conclusion all URLS with "entry" should be only using /blog/ without /entry/
Do you understand? Can anyone help?
You can use Redirect directive.
Redirect 301 /blog/entry/ http://example.com/blog/
This will 301 redirect all requests from example.com/blog/entry/foobar to http:// example.com/blog/foobar .

Can't use ? when redirect 301 with .htaccess

I have a website which is being renewed.
It has url's like site.com/page.php?p=company&l=nl
The new URL is site.com/company
I would like to use .htaccess to redirect 301.
(I would like to keep the SEO pagerank for the old pages)
Because of the ? it doesn't work.
This is the rule I use in my htaccess which doesn't work:
Redirect 301 /page.php?p=company&l=nl http ://www.site.com/company
This is the rule I use in my htaccess which does work:
Redirect 301 /page.php http ://www.site.com/company
I need the ?p=...
This should work:
RewriteCond %{QUERY_STRING} ^p=company&l=nl$ [NC]
RewriteRule ^page\.php$ http ://www.site.com/company? [R=301,NE,NC,L]
Remove the space between http and :

Magento htaccess redirection 301

I am trying to redirect to some magento urls to http
My current url are
https://www.amitbera.com/shop.html
https://www.amitbera.com/shop/abc.html
https://www.amitbera.com/shop/abc.html
https://www.amitbera.com/shop/jde.html
https://www.amitbera.com/shop/fg.html
https://www.amitbera.com/shop/fg/gyt.html
https://www.amitbera.com/shop/fg/gyt/test.html
I want to redirect all shop url to http url .Just like mysql function like function shop% redirect to 301 https to http
http://www.amitbera.com/shop.html
http://www.amitbera.com/shop/abc.html
http://www.amitbera.com/shop/abc.html
http://www.amitbera.com/shop/jde.html
http://www.amitbera.com/shop/fg.html
http://www.amitbera.com/shop/fg/gyt.html
http://www.amitbera.com/shop/fg/gyt/test.html
You can change this in the Magento Admin panel.
System -> Configuration -> Web -> Secure
Use Secure URL's in Frontend: Yes
Set that option to no, and it should redirect to http:// automatically.
This code for solved this problem
Options +FollowSymLinks
RewriteEngine on
RewriteEngine on
RewriteCond %{SERVER_PORT} ^443$
RewriteRule ^(shop|blog|stockists|inthepress|contacts|review|home) http://www.example.com%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTPS} on
RewriteRule ^$ http://%{HTTP_HOST} [L,R]
Thanks!!!!!!!!

Stopping URL rewrite if request is from specific subdomain

Is there a way to stop .htaccess from rewriting a URL if it is from a specific domain?
For example:
example.com/test usually rewrites to example.com/pages/test.php
beta.example.com/test will NOT rewrite. So goes to beta.example.com/test (same)
Basically, what is the rule that looks for a subdomain and stops all rewrites after it?
Add this to the top of your htaccess file:
RewriteCond %{HTTP_HOST} ^beta\.example\.com$ [NC]
RewriteRule ^ - [L]
This will make it so if the request is for beta.example.com it passes the URI through the entire rewrite engine without messing with it.

How to create permalink in htaccess

I want to redirect a link to another with .htaccess file in Linux host. Can you help me?
from: http://example.com/examp
to: http://example.com/examp.php
And another one for my other site
from: http://example.com/examp
to: http://example.com/user.php?u=examp
You will need mod_rewrite enabled for this. Start with placing these lines into .htaccess:
RewriteEngine On
RewriteBase /
TBH I'm not 100% sure what do you mean exactly by permalink and how do you want to redirect, so I will provide 2 variants for each URL: rewrite (internal redirect) and redirect (301 Permanent Redirect).
1. This will rewrite (internal redirect) request for http://example.com/examp to http://example.com/examp.php while URL will remain unchanged in browser:
RewriteRule ^examp$ examp.php [L]
2. This will do the same as above but with proper redirect (301 Permanent Redirect) when URL will change in browser:
RewriteRule ^examp$ http://example.com/examp.php [R=301,L]
3. This will rewrite (internal redirect) request for http://example.com/examp to http://example.com/user.php?u=examp while URL will remain unchanged in browser:
RewriteRule ^examp$ user.php?u=examp [QSA,L]
4. This will do the same as above but with proper redirect (301 Permanent Redirect) when URL will change in browser:
RewriteRule ^examp$ http://example.com/user.php?u=examp [QSA,R=301,L]
Useful link: http://httpd.apache.org/docs/current/rewrite/
You will need mod_rewrite enabled for this
from: http://example.com/123
to: http://example.com/index.php?q=123
RewriteEngine on
RewriteBase /
RewriteRule ^/?([-A-Za-z0-9]+)/?$ index.php?q=$1 [QSA,L]
You'll want to look at RewriteRules and know/understand regular expressions. It'll be something like this:
RewriteEngine on
RewriteRule ^(.*)\/examp$ /examp.php [R=301,L]
- and -
RewriteRule ^(.*)\/[a-zA-Z0-9\-\_\.]+$ /user.php?u=$1 [R=301,L]
The latter example will take what's in-between the [] and place it in the $1 variable
Here is a good link to get you started:
http://www.webweaver.nu/html-tips/web-redirection.shtml

Resources