htaccess for dev文件夹

时间:2017-02-21 10:07:00

标签: php apache .htaccess

你好我在同一台服务器上有一个prod和dev文件夹,两个文件夹上有相同的文件,我的问题是我无法访问我的开发网址

这里是我对根文件夹(prod)的配置

#AuthName "Page d'administration protégée"
#AuthType Basic
#AuthUserFile "/home/XXX/public_html/.htpasswd"
#Require valid-user

RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{THE_REQUEST} ^.*/index\.php 
RewriteRule ^(.*)index.php$ /$1 [R=301,L]

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteRule ^index\.php$ http://www.XXX.fr/ [QSA,L,R=301]
RewriteCond %{HTTP_HOST} ^XX.XX.XX.XX$ [OR]
RewriteCond %{HTTP_HOST} ^XXX.fr$[NC]
RewriteRule ^(.*)$ http://www.XXX.fr/$1 [r=301,nc]
RewriteRule ^(img|cache)($|/) - [L]

RewriteRule ^news/([a-zA-Z0-9\-]+)-([0-9]+)$ article.php?id=$2 [L,QSA]
RewriteRule ^recettes/([a-zA-Z0-9\-]+)-([0-9]+)$ article.php?id=$2 [L,QSA]
RewriteRule ^art$ art.php$1 [L]
RewriteRule ^spots$ spots.php$1 [L]
RewriteRule ^([a-zA-Z0-9_-]+)$ categories.php?cat=$1 [L]

ErrorDocument 404 /index.php
RewriteRule ^(dev/)(.*) /home/XXX/public_html/dev/$2 [L]

我的dev文件夹中的htaccess

AuthName "Page d'administration protégée"
AuthType Basic
AuthUserFile /home/XXX/public_html/.htpasswd
Require valid-user

RewriteEngine on
RewriteBase /dev/

我应该在dev htaccess中复制我的prod中的所有规则吗?

1 个答案:

答案 0 :(得分:0)

对于 / dev 文件夹,您必须修改 .htaccess 文件,更准确地更改:

RewriteBase /

为:

RewriteBase /dev

之后再试一次!