[英]Url redirect from one to another url using htaccess
目前这是在我的 .htaccess 文件中
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /dev/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /dev/index.php [L]
</IfModule>
但是,当用户输入这个 url http://test-site.com
,应该重定向到http://test-site.com/dev/
任何人都可以在这方面帮助我吗?
使用您显示的示例,尝试,请尝试以下 .htaccess 规则文件。 请确保在测试您的 URL 之前清除您的浏览器缓存。 我还在新规则之前和现有规则的小修复之前添加了评论。
<IfModule mod_rewrite.c>
RewriteEngine On
##adding new rule for redirection here...
RewriteRule ^/?$ /dev? [R=301,L]
RewriteBase /dev/
##Added NC flag here for ignore case.
RewriteRule ^index\.php$ - [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /dev/index.php [L]
</IfModule>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.