dongyan9950 2012-09-13 04:35
浏览 25
已采纳

如何为每个请求添加自定义字词到我的域名网址?

Consider my domain name is

www.mydomain.com

Consider a page request

www.mydomain.com/user/register

I want to add a custom word after base URL for every request inside mydomain.com.example

www.mydomain.com/customword/
www.mydomain.com/customword/user/register

Can we do this using URL rewriting in htaccess file ?

Actually it should execute 'www.mydomain.com/user/register' internally...but externally the URL should look like www.mydomain.com/customword/user/register.

  • 写回答

3条回答 默认 最新

  • douyiji3919 2012-09-13 04:39
    关注

    You could create the directory "register", and put an index file inside it that performs the action.

    That's probably the simplest way without url rewriting anyway.


    UPDATE (since the question was updated)

    In .htaccess:

    RewriteEngine On
    RewriteRule ^([A-Za-z0-9-.]+)/user/register/?$ user/register.php?customword=$1
    

    register.php will receive a GET request:

    //User went to www.mydomain/word/user/register
    echo $_GET['customword']; // will return word in this case
    

    Make sure that you have mod_rewrite enabled :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了