Redirect page via htaccess - .htaccess

hello I have an indexed page, whose url: website.ext/recensione/43-Dungeons--Dragons-Neverwinter-PS4
Unfortunately I had to change the structure in the url: website.ext/recensione/43-dungeons--dragons-neverwinter-neverwinter---un-dd-allennesima-potenza
There is no way to make the redirect via .htaccess?

Add this rule to your htaccess file and it will work.
RewriteRule ^recensione/43-Dungeons--Dragons-Neverwinter-PS4$ /recensione/recensione/43-dungeons--dragons-neverwinter-neverwinter---un-dd-allennesima-potenza? [L,R=301]

Related

How to 301 redirect example.com/http://cnn.com/page to example.com/cnn/page?

I'm setting up a project where users can get information about specific pages.
How can I redirect urls in htaccess that look like:
http://www.example.com/http://www.cnn.com/article1.html
to:
http://www.example.com/cnn/article1.html
It is ok if the htaccess specifies cnn and not all dynamic web addresses.
I tried using 301 directory redirects but I think the "http://" part of it is confusing it.
I tried using 301 directory redirects like the following code, but the http:// part is still confusing it:
RewriteRule ^http://youtube.com/(.*)$ /youtube/$1 [L,R=301]
RewriteRule http://www.example.com/http://youtube.com/(.*)$ /youtube/$1 [L,R=301]
This code below works properly to redirect example.com/youtube.com/watch?v=videoid to example.com/youtube/watch?v=videoid:
RewriteRule ^youtube.com/(.*)$ /youtube/$1 [L,R=301]
but if the user types in a link with http:// in it then the server cannot currently redirect properly.
Even better, if you can remove the /http:// and /https:// altogether from http://example.com/http://url.com and http://example.com/https://url.com to redirect to http://example.com/url.com/ then the redirect code that I have working in the youtube example will fix the issue for all of the domains.
How can I do this?
Thank you!

Using htaccess to change url

I want to change a url like:
dynamicdomain.com/mypage
to
dynamicdomain.com/mydashboard
I want to display the content of mypage but the url that the users will see on the browser will contain mydashboard. How do I do this using .htaccess.
I tried using this:
RewriteEngine On
Redirect 301 /mydashboard /mypage
but this redirects the url:
dynamicdomain.com/mydashboard
to
dynamicdomain.com/mypage
Edit:
Here is another example on what I want to achieve:
I have a folder mypage which can be accessed as:
http://dynamicdomain.com/mypage/
I want the users to see http://dynamicdomain.com/mydashboard/
(mydashboard folder doesn't exists) when they access http://dynamicdomain.com/mypage/
can someone point me in the right direction.
Thanks.
Try these directives:
RewriteEngine On
RewriteRule ^mypage$ /dashbord [NC,L]
Redirect directive does an external redirect (redirects a URL to another URL). To redirect "dashboard" internally to "/mypage", you need to use the RewriteRule directive of the Rewrite module.
Put this in your htaccess file :
just after IfModule closes
Redirect 301 /mypage http://www.dynamicdomain.com/mydashboard
This will work for you.
thanks

redirect directory to domain htaccess without changing domain url

I have a site sub.domain1.com
But i would like to access to it from the following url: domain2.com/folder
Here is the .htaccess file in domain2.com
RewriteEngine on
RewriteBase /
RewriteRule ^folder/(.*) http://sub.domain1.com/$1 [L,R=301]
This redirection works well but i wouldn't like to change the url to sub.domain1.com
I want to display the content of sub.domain1.com by using the url domain2.com/folder without changing url.
Thanks in advance

How to redirect a specific page using htaccess

I've looked all over for the htaccess code to redirect a single page and haven't had any luck with many solutions.
Basically I need to redirect this:
/example/my-stuff/
to:
/example/home/
but I don't want any other pages except for /my-stuff/ to be redirected. Eg. these pages should not be redirected and kept the same.
/example/my-stuff/a-page
/example/my-stuff/anything
In the htaccess file in your document root, you can add either this:
RedirectMatch 301 ^/example/my-stuff/$ /example/home/
Or you can use mod_rewrite instead:
RewriteEngine On
RewriteRule ^example/my-stuff/$ /example/home/ [L,R=301]

How can I forward ALL pages to the same exact page on a different domain using .htaccess?

How can I do a 301 redirect of ALL pages on a site to the same exact page on a different domain using .htaccess?
For example, forward:
www.currentdomain.com/page1.php
www.currentdomain.com/page2.php?p=1&t=75
www.currentdomain.com/archived/old/page100.php
To:
www.newdomain.com/page1.php
www.newdomain.com/page2.php?p=1&t=75
www.newdomain.com/archived/old/page100.php
According to about.com's article, the following should redirect ALL traffic to a new domain:
RewriteEngine ON
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]
In the root of your website add in the .htaccess file:
Redirect 301 /page1.php www.newdomain.com/page1.php
Without mod_rewrite you can't transfer the parameters. Further you have to have 1 line per existing file with .htaccess that you want to forward.
I know you didn't ask, but you can do the entire domain including the parameters with 1 line using mod_rewrite.

Resources