htaccess - 301 redirect - .htaccess

I want to redirect
http://www.mysite.com/index.php?channels=browse&channel_id=1&sort=rated
to
http://www.mysite.com/category/cars/?r_sortby=highest_rated&r_orderby=desc
Can someone to help-me with this issue?
Thank you!

This should work for you
RewriteEngine on
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /index\.php\?channels=browse&channel_id=1&sort=rated\ HTTP
RewriteRule ^ /category/cars/?r_sortby=highest_rated&r_orderby=desc? [R=301,L]
EDIT:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/category/(.*)
RewriteRule ^(.*)$ /watch.php?tag=$1 [L]

Related

QUERY_STRING rewrite is not being accounted for

I have the following:
RewriteEngine On
RewriteCond %{QUERY_STRING} !embed=true [NC]
RewriteRule ^/?wiki/old-page$ /wiki/new-page [L,R]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/wiki/index.php [L]
However, when I go to
/wiki/old-page
instead of redirecting to
/wiki/new-page
it redirects to
/wiki/Old-page
What am I doing wrong? Thank you in advance.

Https and htaccess

I'm trying to redirect all http url to https.
I'm struggling because I need to preserve my current redirections here :
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.html?user=$1 [L,QSA]
Can you help me modify this code to include de https redirection. Thanks
Use the following rules:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.html?user=$1 [L,QSA]

Changing URL .htaccess

From this:
http://ice-phoenix.dx.am/jlpt/form/try_question.php
To This:
http://ice-phoenix.dx.am/jlpt/try_question
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^jlpt/form/try_question\.php$ jlpt/try_question/ [L]
Can any help me?
Thank you so much.
Try this in Root/.htaccess file
RewriteEngine On
RewriteCond %{THE_REQUEST} /jlpt/form/([^.]+)\.php [NC]
RewriteRule ^ /jlpt/%1? [R,L]
RewriteRule ^jlpt/([^/]+)/?$ /jlpt/form/$1.php [L,NC]

htaccess redirect rule throws a 500 error

I have the following content in my htaccess:
RewriteEngine On
RewriteRule ^([A-Za-z0-9]+).html$ http://www.somedomain.net/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?(.*?)/?$ index.php?s=$1 [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ index\.php\?s=([^\s]*)
RewriteRule ^/?(.*?)/?$ %1?%2%3 [L,R=301]
This is supposed to convert queries into user friendly URLs. I had used this same htaccess on other servers before and it always worked but on some server I get a 500 error. What could be the reason?
Thank you.
You need to reorder your rules:
RewriteEngine On
RewriteBase /
RewriteRule ^([A-Za-z0-9]+)\.html$ /$1 [R=301,L,NE]
RewriteCond %{THE_REQUEST} \s/+index\.php\?s=([^\s&]+) [NC]
RewriteRule ^ %1? [L,R=301,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?(.+?)/?$ index.php?s=$1 [L,QSA]

language redirect from GET parameter htaccess

I have this code, it redirecs www.example.com?index.php?q=home&lang=en into www.example.com/home. I would like to redirect it into www.example.com/en/home. Is it possible?
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ index.php?q=$1&lang=$2 [L,QSA]
RewriteRule ^([^/]*)(.*)$ $1[L,QSA]
Thanks in advance
Try:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z]{2})/(.*)$ /index.php?q=$2&lang=$1 [L,QSA]

Resources