.htaccess用页面名slash GET参数重写url

.htaccess用页面名slash GET参数重写url,.htaccess,mod-rewrite,parameters,url-rewriting,get,.htaccess,Mod Rewrite,Parameters,Url Rewriting,Get,我正在尝试将我的URL从request/2重写为request?number=2 我试图在我的.htaccess RewriteEngine ON RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^request/(.*)$ request?number=$1 [NC,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{

我正在尝试将我的URL从
request/2
重写为
request?number=2

我试图在我的
.htaccess

RewriteEngine ON

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^request/(.*)$ request?number=$1 [NC,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
但结果是一个
404错误


有人能帮我吗?

有了你们展示的样品,你们能试试下面的吗。请在测试URL之前清除浏览器缓存

RewriteEngine ON
##To remove .php extension eg--> someone hits http://localhost:80/test.php it will redirect to http://localhost:80/test  
RewriteCond %{THE_REQUEST} \s([^.]*)\.php\s [NC]
RewriteRule ^ %1 [R=301]
 #RewriteRule ^(.*)$ $1.php [L]

##All non-existing files/directories will come in this rule whose URI starts from request. 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^request/([\w-]+)/?$ request.php?number=$1 [NC,L,QSA]

##All non-existing files/directories will come in this rule set apart from URI which starts from request which is taken care above.   
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

试试:
RewriteRule^request/([\w-]+)/?$request.php?number=$1[NC,L,QSA]
它可以工作,谢谢!有没有办法避免写扩展名呢@为什么要避免?扩展并没有显示在URL中,它只是在规则中使用。有一些错误,它会返回一个错误500@IvanCisternino,好的,请让我知道你正在点击的url(这里有一个示例url会有帮助)。错误是删除了扩展名,在前5行@RavindersingH13中,我想我已经修复了错误。@IvanCisternino,这似乎是浏览器缓存问题。尝试使用其他浏览器测试URL