[英]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.