2013-01-24 65 views
0

我已經在PHP MVC中創建了一個應用程序,並且http請求類似於 domain.com/index.php?controller/action,我想刪除index.php?和最終的url看起來像http://domain.com/controller/action。 任何幫助將高度讚賞刪除「index.php?」從http://domain.com/index.php?controller/action

目前我的.htaccess文件看起來像下面

RewriteEngine On 
RewriteBase/
<IfModule mod_rewrite.c> 
# Removes index.php from ExpressionEngine URLs 
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php/$1 [L] 
</IfModule> 

它僅刪除index.php文件和URL成爲http://domain.com/?controller/action, 我想,「?」從網址關閉。

+0

可能重複http://stackoverflow.com/questions/4365129/htaccess-remove-index-php-from-url&還有更多。 – Rikesh

+0

研究之前問問題 –

+0

但它並沒有刪除「?」符號,我想刪除index.php以及「?」。我試過這個:^(。*)$ /index.php?/$1 [L]但顯示錯誤。 –

回答

1

使用mod_rewire模塊來完成這項工作。你在問什麼是SEO友好的網址。如果你搜索一下搜索,你會發現很多例子。

把這個放在你的根.htaccess文件中。

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php?/$1 [L] 
+0

感謝您的回覆!我試過了,但它只是刪除index.php和url成爲http://domain.com/?controller/action,我想要「?」從網址關閉。 –

+0

刪除?看看 – Techie