Forum Moderators: phranque
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^landingeu$ /campaign_temp [L]
RewriteRule ^landingeu/$ /campaign_temp [L]
#RewriteCond %{HTTP_HOST} !^example.eu [NC]
#redirect url .eu and .it to http://www.example.eu
RewriteCond %{HTTP_HOST} ^www.example.it [OR]
RewriteCond %{HTTP_HOST} ^example.it
RewriteRule (.*) http://www.example.eu/$1 [R=301,L]
#redirect url without www to http://www.example called extension
RewriteCond %{HTTP_HOST} !^www
RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{SERVER_PORT} ^443$x
#rules for admin directory
RewriteCond %{REQUEST_URI} !^/admin/.*
# we skip all files with .something
RewriteCond %{REQUEST_URI} \..+$
RewriteCond %{REQUEST_URI} !\.php$
RewriteCond %{REQUEST_URI} !\.json$
RewriteCond %{REQUEST_URI} !\.wsdl$
RewriteCond %{REQUEST_URI} !\.gif$
RewriteCond %{REQUEST_URI} !\.swf$
RewriteRule .* - [L]
# we check if the .html version is here (caching)
RewriteRule ^$ index.php [QSA]
RewriteRule ^([^.]+)$ $1.php [QSA]
RewriteRule ^dir1/$ http://www.example.eu/dir1/index.php$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
[L] flag to EVERY RewriteRule. RewriteRule ^landingeu$ /campaign_temp [L]
RewriteRule ^landingeu/$ /campaign_temp [L] RewriteRule ^landingeu/$ http://www.example.eu/landingeu$ [R=301,L] /campaign_temp path back out on to the web as a new URL. RewriteRule ^dir1/$ http://www.example.eu/dir1/index.php$1 [R=301,L] www.example.eu/dir1/ you redirect user to different URL. Never redirect TO a URL with named index file in. Additionally, $1 is undefined in this rule. The DirectoryIndex index.php directive would allow you to serve the index file at the www.example.eu/dir/ URL. #RewriteCond %{HTTP_HOST} !^example.eu [NC] redirects example.es requests to www.example.eu. RewriteCond %{REQUEST_URI} !\.php$
RewriteCond %{REQUEST_URI} !\.json$
RewriteCond %{REQUEST_URI} !\.wsdl$
RewriteCond %{REQUEST_URI} !\.gif$
RewriteCond %{REQUEST_URI} !\.swf$ RewriteCond %{REQUEST_URI} !\.(php|json|wsdl|gif|swf)$ [QSA] is the default action and does not need to be specified. The [L] flag is required here.
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
#redirect url .eu and .it to http://www.example.eu
RewriteCond %{HTTP_HOST} ^www.example.it [OR]
RewriteCond %{HTTP_HOST} ^example.it
RewriteRule (.*) http://www.example.eu/$1 [R=301,L]
#redirect url without www to http://www.example.called_extension
RewriteCond %{HTTP_HOST} !^www
RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L]
# we skip all files with .something
RewriteCond %{SERVER_PORT} ^443$x
RewriteCond %{REQUEST_URI} !^/admin/.*
RewriteCond %{REQUEST_URI} !\.(php|json|wsdl|gif|swf)$
RewriteRule .* - [L]
# we check if the .html version is here (caching)
RewriteRule ^$ index.php [QSA]
RewriteRule ^([^.]+)$ $1.php [QSA]
# no, so we redirect to our front web controller
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>