我的 .htaccess 中有一个简单的 mod_rewrite 规则,用于将友好的 URL 重定向到脚本

发布于 2024-10-05 05:17:48 字数 495 浏览 0 评论 0原文

嗨,我想重写 http://www.domain.com/site_reg/index.php< /a> 到 http://www.domain.com/signup 我该怎么做。 www.domain.com 和domain.com 都适用吗?

编辑:也许我把它倒退了...用户输入 http://www.domain.com/signuphttp://www.domain.com/site_reg/index.php 加载页

hi i'd like to rewrite http://www.domain.com/site_reg/index.php to http://www.domain.com/signup how would I do this. both for www.domain.com and domain.com?

EDIT: maybe i have it backwards... user types in http://www.domain.com/signup and http://www.domain.com/site_reg/index.php load the page

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

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

发布评论

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

评论(3

橘寄 2024-10-12 05:17:48

假设您在 VirtualHost 中设置了 ServerName 和 ServerAlias,这适用于 www.domain.com 和 domain.com
尝试:

<VirtualHost>
  ServerName domain.com
  ServerAlias www.domain.com

  RewriteEngine On
  RewriteRule ^/site_reg/(.*) /signup/$1 [R=301,L]
</VirtualHost>

您想要分配 301 重定向来告诉搜索引擎、浏览器等该页面已永久移动。如果移动不是永久的,请使用临时状态代码:307

This will work for both www.domain.com and domain.com, assuming you have ServerName and ServerAlias set in your VirtualHost
Try:

<VirtualHost>
  ServerName domain.com
  ServerAlias www.domain.com

  RewriteEngine On
  RewriteRule ^/site_reg/(.*) /signup/$1 [R=301,L]
</VirtualHost>

You want to assign a 301 Redirect to tell search engines, browsers, etc. that the page has permanently moved. If the move is not permanent, use the temporary status code: 307

日暮斜阳 2024-10-12 05:17:48

尝试:

RewriteEngine on    
RewriteCond %{HTTP_USER_AGENT} !FeedBurner
RewriteRule ^site_reg\/index\.php$ http://www.domain.com/signup [R,L]

Try:

RewriteEngine on    
RewriteCond %{HTTP_USER_AGENT} !FeedBurner
RewriteRule ^site_reg\/index\.php$ http://www.domain.com/signup [R,L]
无可置疑 2024-10-12 05:17:48

将其放入您的基本 .htaccess 中:

RewriteEngine on
RewriteRule ^site_reg/index\.php$  http://www.domain.com/signup [R,L]

Put this in your base .htaccess:

RewriteEngine on
RewriteRule ^site_reg/index\.php$  http://www.domain.com/signup [R,L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文