我希望用戶能夠使用$_SERVER['PATH_INFO']
作爲一個佔位符的文件服務,並在地址欄htaccess的重定向刪除的index.php
比如我想爲me.com/index.php/settings1
爲me.com/settings1
擺脫的index.php對於用戶轉到的任何PATH_INFO等等。
我該如何將它寫成htaccess規則?我甚至不知道從哪裏開始
如果有幫助,我參與了hostgator的共享託管計劃。
基於@EddyFreddy的建議,我試了兩種方式提到的問題,沒有運氣。下面是該文件的樣子至今:
suPHP_ConfigPath /home/user/php.ini
<Files php.ini>
order allow,deny
deny from all
</Files>
RewriteEngine On
RewriteBase/
RewriteCond %{HTTP_HOST} ^www.mysite.com$ [NC]
RewriteRule .? http://mysite.com%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L] # tried with and without the `?`
看到這個[問題] [1] [1]:http://stackoverflow.com/questions/4365129/htaccess-remove-index-php-from-url – 2012-03-19 03:58:54
@EddyFreddy:它不工作,請參閱編輯 – qwertymk 2012-03-19 10:55:07
@EddyFreddy:經過進一步檢查,我發現我不需要*在地址欄中有'index.php',但我也希望它在那裏被刪除。例如'me.com/settings1'可以工作,但我也希望將'me.com/index.php/settings1'重定向到'me.com/settings1' – qwertymk 2012-03-19 11:02:31