正则表达式 – 使用htaccess将路径目录附加到url
发布时间:2020-12-14 05:48:14 所属栏目:百科 来源:网络整理
导读:我怎么能让Apache重定向 http://localhost/index.phphttp://localhost/create/index.phphttp://localhost/create/contact.phphttp://localhost/engage/page1/services.php 至 http://localhost/Project1/index.phphttp://localhost/Project1/create/index.ph
我怎么能让Apache重定向
http://localhost/index.php http://localhost/create/index.php http://localhost/create/contact.php http://localhost/engage/page1/services.php 至 http://localhost/Project1/index.php http://localhost/Project1/create/index.php http://localhost/Project1/create/contact.php http://localhost/Project1/engage/page1/services.php 分别? 基本上我需要将“Project1”(或我认为合适的其他任何字符串)附加到url路径的BEGINNING 谢谢 解决方法
您可以像这样使用负向前瞻:
Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / # If the request is not for a valid file RewriteCond %{REQUEST_FILENAME} !-f # If the request is not for a valid directory RewriteCond %{REQUEST_FILENAME} !-d # redirect to /Project1/ if it is not already /Project1/ RewriteRule ^((?!Project1/).*)$Project1//$1 [L,NC] (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |