[英]htaccess tidy up url
So I have been trying to get my url to look better, but I can not get it to work as I want, so there might be some nice soul here that can help me out. 因此,我一直在尝试使自己的url看起来更好,但我无法使其按需运行,因此这里可能会有一些不错的灵魂可以帮助我。
I need help with 我需要帮助
ex: www.domain.com/project/index.php?p=settings&u=123&l=k 例如:www.domain.com/project/index.php?p = settings&u = 123&l = k
To look like www.domain.com/project/settings 看起来像www.domain.com/project/settings
I want index.php to be removed and all that comes after the first variable, in this case, p=settings, and also remove ?p= 我希望删除index.php并删除第一个变量之后的所有字符(在本例中为p = settings),还要删除?p =
I got this now 我现在知道了
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]
There is the Possibility to redirect errorcodes 有重定向错误代码的可能性
ErrorDocument 404 /index.php
In this way you can ask for www.domain.com/project/settings
witch does not exist and instead of the error 404 you get redirected to /index.php 这样,您可以请求www.domain.com/project/settings
不存在,并且将错误404重定向到/index.php,而不是错误404。
$uri_asked = explode("/", $_SERVER['PHP_SELF']);
then you have 那你有
$uri_asked[3]="project";
$uri_asked[4]="settings";
and you can build something like 你可以建立像
include("www.domain.com/index.php?p=".$uri_asked[3]."&u=".$uri_asked[4]);
You can use this rule to discard unwanted query string: 您可以使用以下规则丢弃不需要的查询字符串:
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.