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条)

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题