htaccess przekierowania

KLASYCZNY


RewriteEngine on
RewriteCond %{HTTP_HOST} !^www. 
RewriteRule ^(.*)$http://www.%{HTTP_HOST}/$1 [R=301,L] 

—————————————————————————-


RewriteEngine On 
RewriteBase / 
RewriteCond %{HTTP_HOST} ^nazwadomeny.pl$ 
RewriteRule ^(.*) http://www.nazwadomeny.pl/$1 [QSA,L,R=301] 

——————————————————————————————–


RewriteEngine On 
RewriteBase / 
RewriteCond %{HTTP_HOST} ^www.nazwadomeny.pl$ 
RewriteRule ^(.*) http://nazwadomeny.pl/$1 [QSA,L,R=301] 

———————————————————————————-


Options +FollowSymLinks 
RewriteEngine On 
RewriteCond %{HTTP_HOST} !^www. 
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] 

————————————————–


Options FollowSymLinks 
RewriteEngine On 
RewriteCond %{HTTP_HOST} ^www.domena.pl 
RewriteCond %{REQUEST_URI} ^/index.php$ RewriteRule (.*) http://www.domena.pl/ [R=301,L] 

RewriteCond %{HTTP_HOST} ^domena.pl 
RewriteCond %{REQUEST_URI} ^/index.php$ 
RewriteRule (.*) http://www.domena.pl/ [R=301,L] 

RewriteCond %{HTTP_HOST} ^www.domena.pl 
RewriteCond %{REQUEST_URI} ^/O-firmie,3 
RewriteRule (.*) http://www.domena.pl/ [R=301,L] 

RewriteCond %{http_host} ^www.domena.com.pl [NC] 
RewriteRule ^(.*)$ http://www.domena.pl/$1 [r=301,L] 

————————————————————————



RewriteEngine On 
RewriteCond %{http_host} ^wybory.edu.pl [NC] 
RewriteRule ^(.*)$ http://www.wybory.edu.pl/$1 [r=301,L] 

——————————————————————–


RewriteEngine on # index.php to / 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html\ HTTP/ 
RewriteRule ^(.*)index\.html$ /$1 [R=301,L]

———————————————————————-
PODSTRONY NA PODSTRONY:


RewriteEngine On 
RewriteRule ^szkolenia-obsluga-klienta/?$ /pl/szkolenia-obsluga-klienta/ [R=301,L] 
RewriteRule ^10-zniki/?$ /pl/10-zniki/ [R=301,L] 
RewriteRule ^szkolenia-motywowanie/?$ /pl/szkolenia-motywowanie/ [R=301,L] 
RewriteRule ^szkolenia-lodz/?$ /pl/szkolenia-lodz/ [R=301,L] 

———————-
PODSTRONY NA PODSTRONY 2 TYP:


Redirect 301 /pl/odszkodowanie-za-wypadek-w-pracy.php http://www.abc.com/pl/odszkodowania-za-wypadki-przy-pracy.php 

—————————————————–


RewriteEngine On
RewriteBase / RewriteCond %{HTTP_HOST} ^domena.pl$
RewriteRule ^(.*)$ http://www.domena.pl/$1 [R=301,L]

———————————————————————

RewriteCond %{HTTP_HOST} ^(www\.)?abc.pl [NC]
RewriteRule ^index.html$ http://abc.pl/lang/pl [R=301,L]

RewriteCond %{HTTP_HOST} ^(www\.)?abc.com [NC]
RewriteRule ^index.html$ http://abc.pl/lang/en [R=301,L]

———————————————————
PRZEKIEROWANIE 301 W PHP

<?php 
header("HTTP/1.1 301 Moved Permanently"); 
header("Location: http://www.New-Website.com"); 
?>

—————————-


RewriteEngine On 
rewritecond %{http_host} ^www.abc.pl [nc] 
rewriterule ^(.*)$ http://www.abc.com [r=301,nc] 
rewritecond %{http_host} ^abc.pl [nc] 
rewriterule ^(.*)$ http://www.abc.com [r=301,nc] 
rewritecond %{http_host} ^abc.com [nc] 
rewriterule ^(.*)$ http://www.abc.com/$1 [r=301,nc] 
RewriteRule ^/?$ /pl/ [R=301,L] 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(([^/]+/)*)index\.(html?|php[45]?|[aj]spx?)\ HTTP/ 
RewriteRule index\.(html?|php[45]?|[aj]spx?)$ http://www.abc.com/%1 [R=301,L] 

Wytłumaczenie ze strony: http://www.sitepoint.com/forums/showthread.php?1174324-What-are-pros-and-cons-of-using-R-301-NE-NC-L-instead-of-just-R-301 R=301 tells visitors (SE’s et al) that the redirection is permanent and displays the new link in the browsers’ location box. L tells Apache to stop processing the current pass through mod_rewrite and start the next pass with the new {REQUEST_URI} IMHO, those are the valuable flags (unless you do not want the actual URI to be displayed). NE is an oddball which prevents encoding of special characters in the URI. I can’t imagine why this would ever be used so, IMHO, it’s not necessary. NC specifies that mod_rewrite should NOT care about the case of the characters in the regex. This is valuable when examining the {HTTP_HOST} but can cause UnExPeCtEd and UnDeSiReD results when dealing with URIs, i.e., it’s something to be avoided UNLESS you’re using a RewriteCond to test the contents of the {HTTP_HOST} string.

Reklamy

Skomentuj

Wprowadź swoje dane lub kliknij jedną z tych ikon, aby się zalogować:

Logo WordPress.com

Komentujesz korzystając z konta WordPress.com. Wyloguj / Zmień )

Zdjęcie z Twittera

Komentujesz korzystając z konta Twitter. Wyloguj / Zmień )

Zdjęcie na Facebooku

Komentujesz korzystając z konta Facebook. Wyloguj / Zmień )

Zdjęcie na Google+

Komentujesz korzystając z konta Google+. Wyloguj / Zmień )

Connecting to %s