two - htaccess redirect to subfolder without changing url




HTACCESS Redirect all domain except two files (2)

My actual htaccess redirect my complete old site to my new site, I want to redirect all domain but except two file .php (protectetfile1.php and protectedfile2.php).

This is my htaccess

RewriteEngine On
Rewritecond %{http_host} ^olddomain.org [NC]
Rewriterule ^(.*)$ http://newdomain.net/$1 [L,R=301]

Use this rule:

RewriteEngine On
Rewritecond %{http_host} ^olddomain\.org [NC]
RewriteCond %{REQUEST_URI} !/(protectetfile1|protectetfile2)\.php [NC]
Rewriterule ^(.*)$ http://newdomain.net/$1 [L,R=301]

redirect all older site page except certain file

To exclude the file, put the following condition above your rule :

RewriteCond %{REQUEST_FILENAME} !filename\.php$ 

Your htacess :

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !new.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !filename\.php$ 
RewriteRule ^(.*)$ http://new.com/$1 [L,R=301] 
 RewriteCond %{SCRIPT_FILENAME} !-d  
RewriteCond %{SCRIPT_FILENAME} !-f  

RewriteRule ^(.*)$ index.php?param=$1 [L]