Redirect upload to public/upload - laravel

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

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]

Magento redirect 301 home

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]

mod_rewrite from a subfolder with a querystring to a folder or file

I am trying to redirect from:
http://www.example.com/folder/product.aspx?prodid=146
to
http://www.example.com/folder2/folder3/
The folders referred to here don't really exist. There are other rewrite rules in place which redirect transparently to the actual content.
If I create a directory called 'folder', and put an .htaccess file in it, I can get the redirect working, BUT, other URLs which refer to that folder no longer work. So I have to try and do the redirect from the .htaccess file in the ROOT folder.
I tried this:
RewriteCond %{QUERY_STRING} prodid=146
RewriteRule ^/folder/product.aspx$ /folder2/folder3/? [R]
...but it doesn't work (I get a 404 error). Using identical syntax but omitting the /folder/ from the 2nd line works if the .htaccess is in the folder directory (so I know the above can't be too far off) - but as I said, I cannot do that. I have tried lots of variations but nothing seems to work. Any assistance appreciated.
You need to remove the slash from the start your URL regexp. Like this:
RewriteRule ^folder/product.aspx$ /folder2/folder3/? [R]

Redirecting */test/* in httpd.conf to */* [Removing /test/ in path]

we've been running a test verions of our site at www.mystie.com/test/ and these urls are being used by everyday people... how can i configure httpd.conf to now redirect all these old urls to the / location?
ie,
www.mysite.com/test/image1.jpg
should be:
www.mysite.com/image1.jpg
There are other httpd conf rules in there, so i assume i 'll have to place this up front
Just add these lines:
RewriteEngine on
RewriteBase /
RewriteRule ^test/(.*)$ /$1 [R=301,NC,L]
If lines 1 and 2 have already been set, then you can omit those.
If you prefer, you can add this into your .htaccess file in the root web directory instead. Slightly slower, but saves restarting httpd.
I guess you would need a 301 redirect (which should help in SEO as well)
Redirect 301 /test/ /
Looks like #melkamo has the .htaccess covered.
The alias_module will allow you to do it in httpd.conf
`Redirect permanent /test http://localhost`
It will erase test from the URL if it is the first subdirectory

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