Rewrite rule not work !

Discussion in 'General' started by pardis, Dec 12, 2012.

  1. pardis

    pardis New Member

    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
  2. NiteWave

    NiteWave Administrator

    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]
  3. webizen

    webizen New Member

    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.

Share This Page