2011-04-02 125 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的

休息這個工作對我來說