.HTACCESS redirect /calendar to /events - .htaccess

I need to redirect all traffic from /calendar to /events.
www.domain.com/calendar/sales to redirect to www.domain.com/events/sales
So I need to replace calendar with events anyone who goes to the main calendar page, www.domain.com/calendar will be redirect to www.domain.com/events

Use the rewrite rule
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/calendar.*$
RewriteRule /calendar((/.*)?)$ /events$1 [QSA,R=301]
In your VirtualHost context.
You need to load mod_rewrite for it to work.

You may try something like this:
RewriteEngine On
RewriteRule ^calendar/(.*)$ events/$1 [R=301,L]
Best
Marco

Related

Redirect url with language variable to different url htaccess

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]

htaccess redirect to file except own IP

I'm having a bit of a trouble finding the right way to this:
I'm about to launch a site, www.domain.com, but it's not quite yet ready for the public eyes just yet. So I want to redirect all visitors (except myself) to www.domain.com/teaser.html.
How can I do this, so I keep the site content hidden from visitors, without creating a loop if I redirect base url? How would a htaccess string look like?
If I create something like this:
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_HOST} !^xxx.xxx.xxx.xxx
RewriteRule .* /coming-soon.html [R=302,L]
It just create a loop. How can I do this without creating a loop?
As mentioned in this question.
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !=123.45.67.89
RewriteRule index.php$ /teaser.php [R=301,L]

htaccess redirect a url with a param and remove duplicates

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

Redirect .html but not .html?with=options

I'm currently using an .htaccess to get round a problem with a CMS, nothing major and an htaccess fix is tidy enough.
I'm currently using the format...
redirect 301 /pictures.html http://www.domain.com/gallery.html
The problem though this causes is that the CMS uses pictures.html?vars=here to select galleries and so the redirect breaks this part of it. Is there any way I can redirect pictures.html but not when it has variables attached?
For example, add something like
RewriteCond %{QUERY_STRING} ^$
before your rule.
You can redirect everyone except your webserver by detecting the IP address like so:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REMOTE_HOST} !^123\.45\.67\.89
RewriteRule \.html$ /alternate_page.html [R=301,L]

.htaccess Redirects

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/

Resources