doumu5662 2014-02-24 22:07
浏览 48
已采纳

在本土MVC框架中使用PHP URL屏蔽

I have a MVC app in PHP and it's working well, but I want to have a feature where I can mask URLs, for example I have this URL localhost:1900/index/register which calls from the index.php controller the method register.

However, I only want to show localhost:1900/register as URL and still do the same thing, call from index.php the register method, any ideas on how can I obtain that? I am using Apache with htaccess.

This is the content of htaccess:

RewriteEngine On


php_flag display_errors on
php_value short_open_tag 1
php_value upload_max_filesize 1000M
php_value post_max_size 1000M
php_value max_input_time 300
php_value max_execution_time 300


RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l


RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
  • 写回答

2条回答 默认 最新

  • doubinchou4219 2014-02-24 22:20
    关注

    You should be able to re-write that in your .htccess on Apache, try:

    RewriteRule ^(.*)$ /index/$1/ [L,QSA]

    to rewrite all to index, or:

    RewriteRule ^register$ /index/register/ [L,QSA]

    to rewrite only register

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

报告相同问题?

悬赏问题

  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历