PHP 中查询字符串的 HTACCESS 重写规则
HTACCESS Rewrite Rule for Query String in PHP
我有我的 URL https://example.com/?hfgshdsds.
我需要重写一个规则,即使我删除了问号,link 也会像以前一样工作,所以我的 url 需要是 https://example.com/hfgshdsds .
目前在我的 .htaccess 文件上我只有打开 php 没有扩展名的规则。php .
RewriteEngine On
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) / [R=301,NE,L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]
谢谢!
使用您显示的示例,请尝试遵循 htaccess 规则文件。请确保在测试您的 URL 之前清除您的浏览器缓存。
RewriteEngine On
##keep redirection Rules first then keep rest of rules.
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) / [R=301,NE,L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php/?$ %{REQUEST_FILENAME}.php [QSA,L]
##Adding new rule here for non-existing pages here.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ index.php? [QSA,L]
我有我的 URL https://example.com/?hfgshdsds.
我需要重写一个规则,即使我删除了问号,link 也会像以前一样工作,所以我的 url 需要是 https://example.com/hfgshdsds .
目前在我的 .htaccess 文件上我只有打开 php 没有扩展名的规则。php .
RewriteEngine On
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) / [R=301,NE,L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]
谢谢!
使用您显示的示例,请尝试遵循 htaccess 规则文件。请确保在测试您的 URL 之前清除您的浏览器缓存。
RewriteEngine On
##keep redirection Rules first then keep rest of rules.
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) / [R=301,NE,L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php/?$ %{REQUEST_FILENAME}.php [QSA,L]
##Adding new rule here for non-existing pages here.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ index.php? [QSA,L]