Magento redirect 301 home - magento

I having a problem with google. It has indexed my website with non-friendly url like this
mydomain.com/home?param=22 but I have friendly url.
I'd like to redirect (301) mydomain.com/home?param=22 to mydomain.com/ using htaccess
ps: I'm using Magento.

In your Magento's .htaccess add this line just below RewriteBase line:
RewriteRule ^home/?$ /? [R=301,L,NC]

Related

Redirecting millions of URL from /forum to /forums

I had a forum with /forum but it has changed to /forums
I want to know if there is a single line code which can redirect my old URL to new ones.
It is not simple redirection from /forum to /forums
The URL after /forum/abc.html are now /forums/abc.html
There are some 500000 URL that need to be changed. Could anybody help?
For example:
example.org/forum/topic/144934-pio-threatened-rti-applicant/ is now example.org/forum**s**/topic/144934-pio-threatened-rti-applicant/
If you see above the change is just 'S' for all the 500000 URLs
I have already tried this:
RewriteEngine On
RewriteRule ^forum/(.*)$ /forums/$1 [NC,L]

Redirect upload to public/upload

I want force website redirect from https://tutorials.originersmc.com/uploads/ to https://tutorials.originersmc.com/public/uploads/
I know is using .htaccess, but I don't know code.
Any answer to add that redirect?
Try this, it redirects the user to public/uploads when the folder /uploads is requested
RewriteEngine On
RewriteRule ^uploads$ https://tutorials.originersmc.com/public/uploads/ [R=301,L]
I'd add this line to the .htaccess file when your site supports relative links:
Redirect 301 /uploads /public/uploads
For absolute links use this:
Redirect 301 /uploads/ https://tutorials.originersmc.com/public/uploads/
When someone accesses /uploads he will be redirected to /public/uploads
Make sure to edit the .htaccess file with a proper text editor.
Route::redirect('/uploads', '/public/uploads', 301);
Does the same when defined in web.php

Mod Rewrite Rule redirects

I was trying to password protect a folder on our server. However, each time I included .htaccess to that folder, and .htpasswd, it was automatically redirecting everyone to a 401 page without any login prompt.
When i visited my root directly, i saw this .htaccess:
RewriteBase /
RewriteEngine on
#RewriteCond %{HTTP_HOST} ^www\.(.+)
#RewriteCond %{HTTPS}s/%1 ^(on(s)|offs)/(.+)
#RewriteRule ^ http%2://%3%{REQUEST_URI} [L,R=301]
I commented it out and my .htpasswd & .htaccess to the foldr works, however, as my mod rewrite isn't the best, I wasn't sure if commenting the above will create problems for my website?
thanks.
This is basically just redirecting any www.host.ext to host.ext, and returns a 301 Moved Permanently response code.
If you don't care about that functionality you should be able to comment it out.
post your subdirectories htaccess file and we can see if we can sort your original issue out.

mode rewrite redirecting directory to another wont work

alright so i have a need for mode rewrite and i am completely noob/new to it.
I've read sever guide. that explained mode rewrite goes - pattern - redirection - flags.
i am trying to redirect anyone that gets into domain.com/product/ to domain.com/product.php
and pass the variable url=232 however i am first trying to redirect /product/ to product.php
Here is what i got so far.
Options +FollowSymLinks
RewriteEngine On
RewriteRule \/product\/ /product.php
I've started even more basic then that by redirect product.php to index.php and that worked.
am i doing something wrong ?
RewriteEngine On
RewriteBase /
RewriteRule ^product/?$ /product.php?url=232

form post to mod_rewrite url

I am trying to submit a form to the url "localhost/login". Inside my login directory I have an index.php file with the code I am using to debug that the post is working:
<?php
echo $_POST['username'];
?>
I have a .htaccess file inside my login directory:
RewriteEngine on
RewriteRule ^. index.php [L]
The problem is, when I post to localhost/login my firebug shows that the initial POST goes through, but then redirects to login.php as a GET request without any POST variables...
POST
http://localhost/login?password=test_password&remember=true&username=test_username
301 Moved Permanently
GET
http://localhost/login/
200 OK
Any tips would be great.
Thanks
I have a condition in my .htaccess file:
RewriteBase /
RewriteCond %{HTTP_HOST} !^www(.*)
RewriteRule ^(.*) http://www.%{HTTP_HOST}%{REQUEST_URI}
which rewrites any links without the prefix "www". Like this:
http://mysite.com to http://**www**.mysite.com
And that was the problem I had:
in my form I have forgotten to put the "www" and so my POST array was empty.
Putting the www in the form like this:
action="http://www.mysite.com/login"
instead of:
action="http://mysite.com/login"
fixed the problem for me.
Based on my research, POST should be allowed to be rewritten and come out as POST, any sort of problem is probably due to something else going wrong, like your code.
Btw, in general, to keep the GET parameters from being stripped, use the QSA directive:
[QSA,L]

Resources