htaccess整理网址
问题描述:
所以我一直试图让我的网址看起来更好,但我不能让它按我的意图工作,所以这里可能会有一些不错的灵魂可以帮助我。htaccess整理网址
我需要
前帮助:www.domain.com/project/index.php?p=settings & U = 123 & L =ķ
看起来像www.domain.com/项目/设置
我想使用index.php被删除,所有的第一个可变量之后,在这种情况下,p =设置,并且还去掉?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]
+0
但是,这个剂量只适用于如果u变量= 123和l variabele = k那些变量仅仅是一个例子,有没有办法只是删除曾经到过的地方?因为我有更多的其他变量。 或者我可以在$ 1之后放一个通配符*吗? – MrUnknown
答
存在这样的可能性重定向ErrorCode的
ErrorDocument 404 /index.php
通过这种方式,你可以要求www.domain.com/project/settings
巫不存在,而不是错误404,你重定向到的index.php
$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]
[符号的
可能重复:MOD \ _rewrite,URL重写和“相当链接”解释](http://*.com/questions/20563772/reference-mod-rewrite-url-rewriting-and-pretty-links-explained) – deceze