下面是我的.htaccess文件现在。
RewriteEngine叙述上
的RewriteBase /
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^(。*)$ $ 1.PHP [NC,L,QSA]
这工作,因为它使我的网页访问时不使用PHP扩展的事实。
旧= domain.com/test.php
新= domain.com/test
坏的是,当我把得到的数据与下面的链接中的数据不通过。我认为QSA选择这样做,什么交易?
domain.com/test?id=1
解决方案
匹配整个查询字符串,并使用一个反向引用应该把它附加到您的新网址。
RewriteEngine叙述上
的RewriteBase /
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{QUERY_STRING} ^(。*)$
重写规则^(。*)$ $ 1.PHP?%1 [NC,L,QSA]
Here is my .htaccess file right now.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php [NC,L,QSA]
This works in the fact that it makes my pages accessible when not using the .php extension.
Old = domain.com/test.php
New = domain.com/test
The bad thing is that when I send get data with the following link the data is not passed. I thought the QSA option did that, whats the deal?
domain.com/test?id=1
解决方案
Matching the entire query string and appending it to your new URL using a back-reference should work.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)$ $1.php?%1 [NC,L,QSA]