2014-10-10 44 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>