I had to change the name of a subpage and now the problem is that all shared links on Facebook, Twitter, etc. are not working anymore.
That's why I am trying to redirect only a part of a URL with .htaccess but I have no solution yet.
It should work like this:
www.mydomain.com/feeds/details/ --> www.mydomain.com/highlights/details/
I hope you can help me!
It will depend on your server but you are looking for something along these lines
//Rewrite to www
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com[nc]
RewriteRule ^(.*)$ http://www.example.com/$1 [r=301,nc]
//301 Redirect Entire Directory
RedirectMatch 301 /feeds(.*) /highlights/$1
You can try rewriting the URL using RewriteRule, like follows:
.htaccess
RewriteEngine on
RewriteRule ^/feeds/details$ /highlights/details/
Hope, that works for you.
You can find more information here.
I took your tip and adjusted my reality.
My problem:
https://example.com/contact/example.com
My solution:
RedirectMatch 301 (.*)/example.com(.*) $1/$2
After solution, redirect:
https://example.com/contact/
Related
I need to make the following redirection using htaccess (WordPress)
http://oldweb.com/pl/
to https://newweb.com/url/differenturl/
But this redirection should work only for http://oldweb.com/pl/, the urls http://oldweb.com/en/ or http://oldweb.com/il/ should not have any redirection.
My solution works but it works for /en/ and /il/ also:
Redirect 301 http://oldweb.com/pl/ https://newweb.com/url/differenturl/
I'm not a hero in rewriting, sorry :) Can anyone help me with this simple thing?
Redirect matches only REQUEST_URI not full URL with domain protocol etc.
Better to use a RewriteRule just below RewriteEngine On line in your root .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?:www\.)?oldweb\.com$ [NC]
RewriteRule ^pl/?$ https://newweb.com/url/differenturl/ [L,NC,R=301]
I am a beginner in the REWRITING URL and in fact I replaced this link http://www.downisynet.rf.gd/article.php?id=14 with http://www.downisynet.rf.gd/tutoriel/14
Yet both links are still accessible.
So I want to know how to redirect the old URL to the new one?
Here is my .htaccess code:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^tutoriel-([0-9]+) article.php?tutoriel=$1 [L]
Thank you for helping me!
You can simply 301 redirect one page to another using .htaccess. Add the following to your .htaccess file:
RewriteEngine on
Redirect 301 /article.php?id=14 http://www.downisynet.rf.gd/tutoriel/14
Modified rule for /tutoriel/any-digit to /article.php?tutoriel=any-digit
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^tutoriel\/([0-9]+)$ /article.php?tutoriel=$1 [L]
I need to redirect from page
http://masterkanz.com.ua/index.php?route=product/category&path=79_103
to
http://masterkanz.com.ua/pishushchie-prinadlezhnosti/ruchki-sharikovye
Rule like
Redirect 301 /index.php?route=product/category&path=79_103 http://masterkanz.com.ua/pishushchie-prinadlezhnosti/ruchki-sharikovye
doesnt works. I read that problem can be in symbol "?". But what should I do?
Try this,
RewriteEngine On
RewriteCond %{QUERY_STRING} ^route=product/category&path=79_103$
RewriteRule ^index\.php/?$ http://masterkanz.com.ua/pishushchie-prinadlezhnosti/ruchki-sharikovye? [R=301,L]
I've tried this and it is working, you need to use {QUERY_STRING} to get the rule working.
I hope this helps.
I have this url
http://www.mmametals.com.php5-20.dfw1-1.websitetestlink.com/?page_id=61
and i want to redirect to the root like this
http://www.mmametals.com.php5-20.dfw1-1.websitetestlink.com
here is my htaccess
RewriteEngine on
redirect 301 /?page_id=61/ http://www.mmametals.com.php5-20.dfw1-1.websitetestlink.com
but nothing is happening...any ideas
Also I was wondering if there is a way also in .htaccess to delete a duplicate /about ...so for example if the url is
http://somesite.com/about/about
it will rewrite the rule to always be
http://somesite.com/about
RewriteEngine On
RewriteCond %{QUERY_STRING} ^page_id=61$
RewriteRule (.*) http://www.mmametals.com.php5-20.dfw1-1.websitetestlink.com? [R=301,L]
RewriteCond %(REQUEST_URI) ^/about/about[/]?
RewriteRule (.*) http://somesite.com/about? [R=301,L]
should do it.
I don't know the exact answer off the top of my head as I don't work directly with apache that much any longer, but I think you need to look into apache's mod_rewrite module. Try taking a look at:
Apache's mod_rewrite documentation
This post about blocking certain URLS
How do I set up an .htaccess file to redirect requests to another folder on another domain? I don't want the links to break, I just want them to go elsewhere. Say mysite.com/image.jpg would redirect to site2.com/images/image.jpg.
In .htaccess (in Apache at least):
RewriteEngine On
RewriteBase /
RewriteRule ^images/(.*)$ http://www.yahoo.com/blah/$1 [R=302,L]
Now, what a big surprise, the official documentation has lots of useful examples, including what you are looking for. Yeah, it really sucks that Google is down so often.
You could use mod_rewrite to redirect the request. If you want to redirect everything:
RewriteEngine on
RewriteRule ^ http://other.example.com/images%{REQUEST_URI} [L]
And if you just want to redirect requests with a path that end in .jpg:
RewriteEngine on
RewriteRule \.jpg$ http://other.example.com/images%{REQUEST_URI} [L]
This should help:
Redirect 301 / http://www.example.com/