2016-10-10 64 views
0

我的網址是象下面這樣:URL重寫引導

http://localhost/project/test/jobs/?page=accounting 

<a href="<?php echo BASE_URL; ?>jobs/?page=accounting">Accounting</a> 

,我想使象下面這樣:

http://localhost/project/test/jobs/accounting 

我有搜索其它的問題,但無法做到這一點。因爲我完全不知道這個的.htaccess重寫過程:(

但是我有下面的代碼已經在我的htaccess文件刪除PHP擴展:

RewriteEngine On 

# Unless directory, remove trailing slash 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^/]+)/$ http://example.com/folder/$1 [R=301,L] 

# Redirect external .php requests to extensionless url 
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/ 
RewriteRule ^(.+)\.php$ http://example.com/folder/$1 [R=301,L] 

# Resolve .php file for extensionless php urls 
RewriteRule ^([^/.]+)$ $1.php [L] 

請幫我添加URL重寫規則上面htaccess文件沒有鬆動.PHP內線統治。

回答

0

我通常做什麼用的鏈接建設是把我全部的流量到我的index.php whitch將其分解成一個MVC框架,這是我的.htaccess爲您重要部分:

Options +FollowSymLinks 

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

RewriteRule (.*) index.php?path=$1 [L,QSA] 

是什麼這個.htaccess按規則做規則?

Options +FollowSymLinks 

http://www.maxi-pedia.com/FollowSymLinks

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

檢查或請求的文件不是一個目錄或實際文件的直接路徑,糾正我,如果我錯了,因爲我不是100%肯定。

RewriteRule (.*) index.php?path=$1 [L,QSA] 

重寫從 「/測試/ testings/lalalala」 路徑到 「的index.php?路徑= /測試/ testings/lalalala」。

我希望這是您尋找的答案。