[英]Remove the query string from url using htaccess
I need some help with htaccess.我需要一些有关 htaccess 的帮助。 Would you be so kind to assist a little bit?
你能帮点忙吗? I have a URL like this
我有一个这样的网址
https://example.com/index.php?p=application-intelligence
[or] [或者]
https://example.com/?p=application-intelligence
Basically the index.php is passed some parameter 'home' to know which page to load ie home.php So I've tried to follow your post on your blog but with not much luck.基本上 index.php 传递了一些参数“home”来知道要加载哪个页面,即 home.php 所以我试图关注你在你博客上的帖子,但运气不佳。
So I'd like the final code to be所以我希望最终的代码是
https://example.com/application-intelligence https://example.com/application-intelligence
Here's my code.这是我的代码。
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?p=$1
Also for the https://example.com?p=home也适用于https://example.com?p=home
I'd like it to be just我希望它只是
This is what i have in my apache virtual host conf file:这是我的 apache 虚拟主机 conf 文件中的内容:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?$1 [L,QSA]
You may use these rules:您可以使用以下规则:
RewriteEngine on
# handle /?p=home
RewriteCond %{THE_REQUEST} \s/+(?:index\.php)?\?p=home\s [NC]
RewriteRule ^ /? [R=301,L,NE]
# handle /?p=<something>
RewriteCond %{THE_REQUEST} \s/+(?:index\.php)?\?p=([^\s&]+) [NC]
RewriteRule ^ /%1? [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?p=$1 [L,QSA]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.