Rewrite rule not work !

pardis

Well-Known Member
#1
Hello :

It is appear Rewrite_mode rule not worked on sever , this is important rule for almost user.

Example :

RewriteCond %{HTTP_HOST} ^dl\.lianportal\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.dl\.lianportal\.com$
RewriteRule ^/?$ "http\:\/\/lianportal\.com" [R=301,L

Thanks
 

NiteWave

Administrator
#2
try:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^dl\.lianportal\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.dl\.lianportal\.com$
RewriteRule ^(.*)$ http://lianportal.com/$1 [R=301,L]
 

webizen

Well-Known Member
#3
Hello :

It is appear Rewrite_mode rule not worked on sever , this is important rule for almost user.

Example :

RewriteCond %{HTTP_HOST} ^dl\.lianportal\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.dl\.lianportal\.com$
RewriteRule ^/?$ "http\:\/\/lianportal\.com" [R=301,L

Thanks[/QUOTE]

It should work in httpd.conf (not .htaccess) as follows:

RewriteCond %{HTTP_HOST} ^dl\.lianportal\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.dl\.lianportal\.com$
RewriteRule ^/?$ "http\:\/\/lianportal\.com" [R=301,L]

Note that it is for URL contains with "/" or "" ONLY, not for everything else. If you need rewrite for everything else, you should use

RewriteRule ^/(.*)$ "http\:\/\/lianportal\.com/$1" [R=301,L]

/ (slash after ^) is needed if rules are in httpd.conf. No need in .htaccess.

You can put 'RewriteLogLevel 9' in the httpd.conf to enable rewrite logging and grep REWRITE entry in error_log for debugging.
 
Top