2017-07-14 112 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