2011-04-02 127 views
2

对不起我的英文不好...笨的.htaccess

我有最基本的可能笨的设置并不能使它发挥作用......如果我访问的URL http://domain.com/index.php?controllerX/method它工作正常。

现在我希望能够访问routes.php文件“controllerX” http://domain.com/method

我配置是默认的控制器,并尝试使用后续的.htaccess:

RewriteEngine on 
RewriteCond $1 !^(index\.php) 
RewriteRule ^(.*)$ /index.php/$1 [L] 

我有尝试多个.htaccess和每次服务器只返回403错误。即使我的.htaccess仅包含第一行“RewriteEngine on”,它也会显示403个错误。我试图设置每个文件夹chmod 777或755进行测试,这不会改变。

有没有办法看到什么资源给403错误?或者我在其他地方犯了一个错误?

好吧,我readed地方,我需要“选项+ FollowSymLink”在我的htaccess ...与服务器告诉我500错误:(

编辑 好了,现在它的工作,与后续htaccess的:

Options +FollowSymLinks 
Options +Indexes 
RewriteEngine On 
RewriteBase/

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

RewriteCond $1 !^(index\.php) 
RewriteRule ^(.*)$ /index.php/$1 [L] 
+0

该选项被称为+ FollowSymLinks(末尾带有字母'')。 – speedball2001 2011-04-02 17:34:22

+0

你应该忽略最后一次重写cond(在最后一行旁边),在它之前不再需要它。为了安全起见,您应该使用SymLinksIfOwnerMatch而不是FollowSymLinks,它更安全。你的[L]也会比[L,QSA]更好,但我的2美分 – BrandonS 2011-04-09 02:09:44

回答

-1

我认为你的问题也回答here

RewriteEngine On 
RewriteBase/

# Removes trailing slashes (prevents SEO duplicate content issues) 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.+)/$ $1 [L,R=301] 

# Enforce www 
# If you have subdomains, you can add them to 
# the list using the "|" (OR) regex operator 
RewriteCond %{HTTP_HOST} !^(www|subdomain) [NC] 
RewriteRule ^(.*)$ http://www.plugb.com/$1 [L,R=301] 


RewriteBase/ 
RewriteCond %{HTTP_HOST} !="" 
RewriteRule ^index.php(/.*)?$ http://%{HTTP_HOST}$1 [R=301] 
# Checks to see if the user is attempting to access a valid file, 
# such as an image or css document, if this isn't true it sends the 
# request to index.php 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L] 
0

改变你.htaccess文件如:

从我们在.htaccess文件做了变化,我们也必须验证

开/改变以下设置:

阿帕奇阅读的.htaccess位于在/ var/www/html等目录下的文件。

须藤纳米/etc/httpd/conf/httpd.conf中

找到部分,然后更改设置AllowOverride无以

AllowOverride All 

<Directory /var/www/html> 
    AllowOverride All 
</Directory> 
Save and exit. 

现在重新启动Apache: 您可以通过编辑httpd.conf文件做到这一点以使更改生效:

须藤systemctl重新启动httpd的

休息这个工作对我来说