[英]how to rewrite this URL in htaccess
我只想寻求帮助,如果如何在 .htaccess 中做到这一点
示例: https : //sample.com/index.php? url = testimonials重定向到https://sample.com/testimonials
我的 htaccess 规则:
Options -MultiViews
RewriteEngine On
RewriteRule ^home$ https://sample.com/ [R=301,L]
RewriteRule ^url=testimonials$ https://sample.com/testimonials/ [R=301,L]
RewriteRule ^error$ https://sample.com/ [R=301,L]
RewriteRule ^1$ https://sample.com/ [R=301,L]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [L,NE,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
你能不能试试以下。 考虑到您的 htaccess 文件和 index.php 文件都存在于根文件夹中(这些规则是在 OP 共享其他已经存在的 htaccess 规则之前提供的)。
RewriteEngine ON
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)$ index.php?url=$1 [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.