[英]htaccess tidy up url
因此,我一直在尝试使自己的url看起来更好,但我无法使其按需运行,因此这里可能会有一些不错的灵魂可以帮助我。
我需要帮助
例如:www.domain.com/project/index.php?p = settings&u = 123&l = k
看起来像www.domain.com/project/settings
我希望删除index.php并删除第一个变量之后的所有字符(在本例中为p = settings),还要删除?p =
我现在知道了
RewriteEngine On
RewriteBase /
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
旋转一下。
RewriteRule ^project/([^/]*)$ /project/index.php?p=$1&u=123&l=k [L, QSA]
有重定向错误代码的可能性
ErrorDocument 404 /index.php
这样,您可以请求www.domain.com/project/settings
不存在,并且将错误404重定向到/index.php,而不是错误404。
$uri_asked = explode("/", $_SERVER['PHP_SELF']);
那你有
$uri_asked[3]="project";
$uri_asked[4]="settings";
你可以建立像
include("www.domain.com/index.php?p=".$uri_asked[3]."&u=".$uri_asked[4]);
您可以使用以下规则丢弃不需要的查询字符串:
RewriteEngine On
RewriteCond %{THE_REQUEST} /index\.php\?p=([^&\s]+) [NC]
RewriteCond %{REQUEST_URI} !/system/ [NC]
RewriteRule ^(.*?)index\.php$ /$1%1? [R=301,NE,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.