我希望用户能够使用$_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