2014-02-14 145 views
0

所以我一直試圖讓我的網址看起來更好,但我不能讓它按我的意圖工作,所以這裏可能會有一些不錯的靈魂可以幫助我。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] 
+0

可能重複:MOD \ _rewrite,URL重寫和「相當鏈接」解釋](http://stackoverflow.com/questions/20563772/reference-mod-rewrite-url-rewriting-and-pretty-links-explained) – deceze

回答

0

給這個旋轉。

RewriteRule ^project/([^/]*)$ /project/index.php?p=$1&u=123&l=k [L, QSA] 
+0

但是,這個劑量只適用於如果u變量= 123和l variabele = k那些變量僅僅是一個例子,有沒有辦法只是刪除曾經到過的地方?因爲我有更多的其他變量。 或者我可以在$ 1之後放一個通配符*嗎? – MrUnknown

0

存在這樣的可能性重定向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]); 
0

您可以使用此規則放棄不必要的查詢字符串:

RewriteEngine On 

RewriteCond %{THE_REQUEST} /index\.php\?p=([^&\s]+) [NC] 
RewriteCond %{REQUEST_URI} !/system/ [NC] 
RewriteRule ^(.*?)index\.php$ /$1%1? [R=301,NE,L] 
[符號的