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 springboot 3.0 实现Security 6.x版本集成
  • ¥15 PHP-8.1 镜像无法用dockerfile里的CMD命令启动 只能进入容器启动,如何解决?(操作系统-ubuntu)
  • ¥15 请帮我解决一下下面六个代码
  • ¥15 关于资源监视工具的e-care有知道的嘛
  • ¥35 MIMO天线稀疏阵列排布问题
  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)