符号链接重定向到根文件夹

时间:2014-11-20 22:54:00

标签: apache .htaccess mod-rewrite

我正在尝试使用mod_rewrite从此

更改以下网址
example.com/control/service.php?id=1

到这个

example.com/control/service/1

但是当我到达'example.com/control/service/1'时,URL会更改为'example.com/service/1',跳过控件/文件夹并抛出404.

我在控件/文件夹中有.htaccess文件,其中包含以下内容。

RewriteEngine on
Options +FollowSymLinks
RewriteRule ^([a-z]+)$ $1.php [L,NC]
RewriteRule ^service/([0-9]+)$ service.php?id=$1 [L,NC]

感谢任何帮助。

问候。

1 个答案:

答案 0 :(得分:0)

确保关闭多视图,然后尝试添加基础:

RewriteEngine on
RewriteBase /control/
Options +FollowSymLinks -Multiviews

RewriteRule ^([a-z]+)$ $1.php [L,NC]
RewriteRule ^service/([0-9]+)$ service.php?id=$1 [L,NC]
相关问题