URL使用HTACCESS从一个URL重定向到另一个URL

发布于 2025-01-23 16:53:26 字数 302 浏览 2 评论 0原文

这是我的.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>

目前, /代码> 在这方面,有人可以帮我吗?

Currently this is in my .htaccess file

<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>

But when ever user enters this url http://test-site.com should redirect to http://test-site.com/dev/
Could any one please help me in this regard?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

趁微风不噪 2025-01-30 16:53:26

尝试显示样本,尝试,请尝试遵循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>

With your shown samples, attempts, please try following htaccess rules file. Please make sure to clear your browser cache before testing your URLs. I have also put comments before new rule and before a small fix in existing rule.

<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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文