2014-10-10 105 views
0

我已經下載並在我的網站安裝http://www.question2answer.org/http://www.yourstartups.com/discussion/(討論子目錄)如何使用htaccess更改網址結構?

當前的URL結構是這樣的:example.com/index.php?qa=123 & qa_1 =爲什麼-DO鳥星 我想更改爲/ 123 /爲什麼-DO鳥星 (爲什麼-DO鳥星是例如查詢)

以下是我的htaccess:

DirectoryIndex index.php 
 
<IfModule mod_rewrite.c> 
 
RewriteEngine On 
 
#RewriteBase/
 
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$ 
 
RewriteRule . %1/%2 [R=301,L] 
 
RewriteCond %{REQUEST_FILENAME} !-f 
 
RewriteCond %{REQUEST_FILENAME} !-d 
 
RewriteRule ^.*$ index.php?qa-rewrite=$0&%{QUERY_STRING} [L] 
 
</IfModule>

任何人都可以幫助我嗎?

回答

0

你需要一個新的規則來重寫你漂亮的URL。

DirectoryIndex index.php 
<IfModule mod_rewrite.c> 
RewriteEngine On 
#RewriteBase/
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$ 
RewriteRule . %1/%2 [R=301,L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?qa=$1&qa_1=$2 [L,QSA] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^.*$ index.php?qa-rewrite=$0 [L,QSA] 
</IfModule>