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

报告相同问题?