2017-07-14 107 views
3

我有一個網站,如www.abc.com/service/page.php?ids=social。我將網站重定向到www.abc.com/service/social。但我需要從url.Ex避免這個文件夾:www.abc.com/social。子文件夾url獲取參數不工作在htaccess

Options +FollowSymLinks -MultiViews 
RewriteEngine on 
RewriteBase /service/ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([a-zA-Z0-9]+|)/?$ page.php?ids=$1 

回答

0

只需從正則表達式匹配排除 「服務」:

RewriteRule ^service/([a-zA-Z0-9]+|)/?$ page.php?ids=$1 
+0

@cweiskeThanks,但它不工作 –

0

將此代碼在網站根目錄的.htaccess(的/service/即父目錄):

RewriteEngine on 
RewriteBase/

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule !^service/ service%{REQUEST_URI} [L,NC] 
+0

它不重定向。 –

+0

它不應該重定向,它只是重寫。當您在瀏覽器中輸入「www.abc.com/social」時,這個.htaccess位於何處?錯誤是什麼? – anubhava