htaccess从www

时间:2017-06-24 04:33:25

标签: php .htaccess redirect cakephp cpanel

我在这个标题上看到了重复,但坦率地说,我是PHP的新手,并不确定htaccess是如何工作的。我从某人那里购买了这个脚本,我没有得到开发者的帮助,这就是为什么我是唯一一个解决这个问题的人。

问题 我的旧脚本是由我制作的,曾经被重定向到 http://socialdealers.in/Deals/ ,新脚本是基于CakePHP的脚本,它显示了索引上的所有内容,但我仍然看到旧的重定向,即使在删除后来自托管的文件。

网站 http://socialdealers.in

  • 有时我会看到更新后的脚本,但有时会重定向 至/ Deals /
  • 尝试清除浏览器缓存和Cookie
  • 尝试使用其他IP从我的手机打开,并使用新脚本。

如果你们不明白我想说的话,我很抱歉,但任何帮助都会受到赞赏。一些开发人员告诉我在stackoverflow上问一个问题并说它的.htaccess问题。

位置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>

位置2 .htaccess 的public_html / socialdealers.in /应用程序/ 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>

位置3 .htaccess 的public_html / socialdealers.in /应用程序/根目录/ 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>

编辑: 问题已在Stackoverflow外部解决。

编辑第3个htaccess文件并将其更改为

# 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 个答案:

答案 0 :(得分:0)

您发布的这两个链接都指向/Deals/,这是一个登录/注册页面。这不是你的目标吗?

(1)如果您认为问题出在.htaccess文件中,您是否可以显示.htaccess的内容,以帮助我们所有人(包括您)解决您的问题。 .htaccess文件位于您的网络服务器上,可能位于您网站的根文件夹中。

.htaccess文件中的简单重定向示例如下所示:

Redirect 301 /OLDFILE.html /NEWFILE.html

在所有页面上使用正则表达式进行重定向的另一个示例,强制非www,可能如下所示:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^YOURDOMAIN.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.YOURDOMAIN.com [NC]
RewriteRule ^(.*)$ http://YOURDOMAIN.net/$1 [L,R=301,NC]

(2)如果您认为问题与您的PhP代码有关,那么您是否还可以发布有关如何设置重定向的更多信息,或者只是显示一些代码。

答案 1 :(得分:0)

解决了外部Stackoverflow。

编辑第3个htaccess文件并将其更改为

# 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>