1
这里是我的.htaccess文件:如何重写URL路径查询字符串
# To remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /(.*)/$
RewriteRule^/%1 [R=301,L]
# To remove .php extension
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\ (.*)\.php [NC]
RewriteRule^%1 [R=301,L]
# To check whether the PHP file exists and set it back internally
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^.*$ $0.php [L]
# To redirect /index to root
RewriteCond %{THE_REQUEST} ^.*/index
RewriteRule ^(.*)index.php$ /$1 [R=301,L]
假设有根目录和V1,V2一个file.php,......是我的查询字符串输入和该URL请求如下:
http://domain.tld/file/v1/v2...
我只需要使用的.htaccess送V1,V2,...如HTTP GET到file.php,它应该与任何其他PHP文件名和在工作的情况下,可能有任何数量的输入,否则处理多达3个输入就足够了。
谢谢,我应该只是没有任何其他的变化在第一我的.htaccess中添加此到以前的代码? – 4L3X
@ 4L3X在删除'.php'后立即放置。 – hjpotter92
不幸的是没有工作,并导致内部服务器错误。 – 4L3X