[英]htaccess remove folder from url only
我试图从我的网址中只删除一个特定的文件夹。 我在这里看到了很多答案,但我找不到对我有用的答案。 我有这个网址http://www.mydomain.com/projects/books/index.php我只想删除项目文件夹,以便可以使用http://www.mydomain.com/books/index.php
我在public_html文件夹中有这个.htacces:
RewriteEngine on
RewriteCond %{REQUEST_URI} !(.*)projects
RewriteRule ^(.*)$ projects/$1 [L]
使用此代码,我可以访问http://www.mydomain.com/books/index.php,但是其他任何地址都可以在projcets文件夹中重定向我,例如http://www.mydomain.com向我显示了/项目的索引谢谢您
您可以尝试以下规则:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/(projects/|index\.php) [NC]
RewriteRule ^(.+)$ /projects/$1 [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.