dongshan4518 2017-06-24 04:33
浏览 70
已采纳

htaccess从www重定向到非www

I saw duplicates on this title but to be frank i'm new to PHP and not sure how htaccess works. I had this script purchased from someone and i am not getting help from that developer which is why i'm the only one to solve this issue.

Issue My old script was made by me which used to be redirected to http://socialdealers.in/Deals/ and the new script is CakePHP based script which shows everything on the index but i still see the old redirection even after removing those files from the hosting.

Website http://socialdealers.in

  • Sometimes i see the updated script but sometimes it gets redirected to /Deals/
  • Tried to clear browser cache and cookies
  • Tried to open from my mobile with a different IP and it works with the new script.

I'm sorry if you guys did not understand what i am trying to say but any help would be appreciated. Some developer told me to ask a question here on stackoverflow and said that its .htaccess problem.

Location 1 .htaccess public_html/socialdealers.in/.htaccess

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule    ^$ app/webroot/    [L]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule    (.*) app/webroot/$1 [L]

RewriteCond %{SERVER_PORT} !^445$
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

</IfModule>
<IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"
</IfModule>

Location 2 .htaccess public_html/socialdealers.in/app/.htaccess

# Use PHP5 as default

#AddHandler application/x-httpd-php54 .php

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*) webroot/$1    [L]
</IfModule>

Location 3 .htaccess public_html/socialdealers.in/app/webroot/.htaccess

# Use PHP5 as default

#AddHandler application/x-httpd-php54 .php

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$  http://%{HTTP_HOST}/$1 [R=301,L]
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

EDIT: Issue Resolved Outside Stackoverflow.

Edited the 3rd htaccess file and changed it to

# Use PHP5 as default

#AddHandler application/x-httpd-php54 .php

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
  • 写回答

2条回答 默认 最新

  • draxu26480 2017-07-24 00:09
    关注

    Resolved Outside Stackoverflow.

    Edited the 3rd htaccess file and changed it to

    # Use PHP5 as default
    
    #AddHandler application/x-httpd-php54 .php
    
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?