.htaccess POST data blocked - php

I send POST data from a form to my root index that will redirect :
<form action="index.php?menu=blog&section=admin" method="post">
But this lines in .htaccess blok POST data :
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule ^(.*) http://www.example.com/$1 [QSA,L]
I'v tried a few other ones but same problem :
#RewriteRule ^(.*) http://www.example.com/$1 [QSA,L,R=301]
#RewriteRule (.*) http://www.example.com/$1 [QSA,L,R=301]
#RewriteRule ^(.*) www.example.com/$1 [QSA,L,R=301]
#RewriteRule ^(.*) http://www.example.com/$1 [QSA,NC,P] #Doesn't rewrite "www"
There are a few other post with similar problem but I don't find my solution
How can I send POST datas to index.php?menu=blog&section=admin ?
Thank you !

Try these rules
Rewriting product.php?id=12 to product-12.html
RewriteEngine on
RewriteRule ^product-([0-9]+)\.html$ product.php?id=$1
Rewriting product.php?id=12 to product/ipod-nano/12.html
RewriteEngine on
RewriteRule ^product/([a-zA-Z0-9_-]+)/([0-9]+)\.html$ product.php?id=$2
Redirecting non www URL to www URL
RewriteEngine On
RewriteCond %{HTTP_HOST} ^viralpatel\.net$
RewriteRule (.*) http://www.viralpatel.net/$1 [R=301,L]
Rewriting yoursite.com/user.php?username=xyz to yoursite.com/xyz
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ user.php?username=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ user.php?username=$1
Redirecting the domain to a new subfolder of inside public_html
RewriteEngine On
RewriteCond %{HTTP_HOST} ^test\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.test\.com$
RewriteCond %{REQUEST_URI} !^/new/
RewriteRule (.*) /new/$1

Related

redirect to www. without lost variables get

I am redirecting via .htaccess so that when they enter my domain.com site it will take them to www.domain.com. This works fine, but when the url contains some get variable it gets lost.
Example:
Entering domain.com/archive.php?var=something.
I get redirected to www.domain.com/archive.php
Losing the get variable var=something...
In my htaccess I have the following:
RewriteRule (.) http://www.example.com/$1 [R=301,L]
#redirigir index.html e index.php a raiz
RewriteCond %{REQUEST_URI} ^/index.php
RewriteRule ^.$ http://%{HTTP_HOST} [R=301,L]
RewriteCond %{REQUEST_URI} ^/index.html
RewriteRule ^.*$ http://%{HTTP_HOST} [R=301,L]
What am I doing wrong?
Hey i think this can work for you
Options +FollowSymlinks -MultiViews
RewriteEngine on
# for http
RewriteCond %{HTTP_HOST} ^(www\.)?domainA\.com$ [NC]
RewriteCond %{SERVER_PORT} =80
RewriteRule ^(.*)$ http://www.domainB.com/$1 [R=301,L]
# for https
RewriteCond %{HTTP_HOST} ^(www\.)?domainA\.com$ [NC]
RewriteCond %{SERVER_PORT} =443
RewriteRule ^(.*)$ https://www.domainB.com/$1 [R=301,L]

Htaccess multiple redirect rules should be working

This should be working according to htaccess tester http://htaccess.madewithlove.be/
I'm trying to get url's in the format subdomain.domain.com to resolve to domain.com/index.php?sub=subdomain
However I've also want any links in the form subdomain.domain.com/pagename to redirect to domain.com/index.php?tpl=page&sub=subdomain&url=pagename
At the moment the first rule works if i remove the second rule but if I include both only the second rule works.
Here's the full htaccess
RewriteEngine On
#EDIT: this was messing it all up by appending index.html so the subdomain only
# wasn't triggering at all due to appended pagename
DirectoryIndex disabled
#Remove www
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
#Rewrite if subdomain only
RewriteCond %{HTTP_HOST} ^(^.*)\.example.com$ [NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ http://example.com/index.php?sub=%1 [P,NC,QSA,L]
#Rewrite if internal page
RewriteCond %{HTTP_HOST} ^(^.*)\.example.com$ [NC]
RewriteRule ^(.+/)?([^/]*)$ http://example.com/index.php?tpl=page&sub=%1&url=$2 [P,NC,QSA,L]
If you answer this I will make you Secretary of State once Flat Earth goes mainstream. Thanks!
Have it like this:
DirectoryIndex disabled
RewriteEngine On
#Remove www
RewriteCond %{HTTP_HOST} ^www\.(example\.com)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L,NE]
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^/?$ index.php [L]
#Rewrite if subdomain only
RewriteCond %{HTTP_HOST} ^(?!www\.)([^.]+)\.(example\.com)$ [NC]
RewriteRule ^index\.php$ http://%2/index.php?sub=%1 [P,QSA,NC,L]
#Rewrite if internal page
RewriteCond %{HTTP_HOST} ^(?!www\.)([^.]+)\.(example\.com)$ [NC]
RewriteRule ^(?:.+/)?([^/]+)/?$ http://%2/index.php?tpl=page&sub=%1&url=$1 [P,QSA,L]

redirecting www. to https

My website url looks like www.[site-name].com
I want to redirect to https://www.[site-name].com on .htaccess with following code.
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301, L]
I copy the file to ftp at this path: httpdocs/.htaccess
But it does not redirect to [site-name].com when I try to load www.[site-name].com. How can I solve this?
Try this:
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,QSA]
If you want to redirect non-www url to www url , for both http and https use this ;
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
If you want to redirect www to non-www url use this ;
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
RewriteCond %{HTTPS_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
or without using domainname ;
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*) http://%1/$1 [R=301,L]
RewriteCond %{HTTPS_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*) https://%1/$1 [R=301,L]

I need to redirect my website link from https://ravisah.in/index.php to ravisah.in by HTACCES file

I want my website to redirect all given below to ravisah.in
https://www.ravisah.in/index.php
www.ravisah.in
www.ravisah.in/index.php
ravisah.in/index.php
Please help me to do this.
My htaccess file code
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^ravisah.in[nc]
RewriteRule ^(.*)$ http://www.ravisah.in/$1 [r=301,nc]
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
ErrorDocument 404 /404.php
You can use the following rule :
RewriteRule ^index\.php$ / [R=301,L]
This will permanently redirect /index.php to / .
I think there is no any solution for this i only have to purchase SSL Certificate for the website.
Use .htaccess file for 301 redirect
RewriteEngine On
RewriteCond %{HTTP_HOST} ^http://www.ravisah.in [NC]
RewriteRule ^(.*)$ http://ravisah.in/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^https://www.ravisah.in/index.php [NC]
RewriteRule ^(.*)$ http://ravisah.in/$1 [L,R=301]
**Used for remove www from url**
RewriteCond %{HTTP_HOST} ^www.ravisah.in [NC]
RewriteRule ^(.*)$ http://ravisah.in/$1 [L,R=301]
**Used for https to http**
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
**Used for remove index.php**
RewriteRule ^index\.php$ / [R=301,L]
For SSl implement You must have SSl certificate

How i can edit my htaccess file to let my site work with "www" only

My .htaccess file code is
DirectoryIndex router.php
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 ^(.*)$
RewriteRule ^(.*)$ router.php?_doroute=$1 [L,QSA]
I want to let my site work with "www" only
i couldn't integrate this code with it
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Can anyone help me please ?
What is the full output of your .htaccess file? You are showing a rule of RewriteRule ^(.*)$ router.php?_doroute=$1 [L,QSA] which indicates stop processing at the end of that rule, [L].
If you are just adding:
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
then that would be your issue.
An alternative method is:
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule (.*) http://www.example.com$1 [R=301]
Just add the folowing to your .htaccess
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
Source:
LetUsLook.nl - Redirect non-www to www

Categories