【问题标题】:introducing .htaccess file in PHP MVC Project在 PHP MVC 项目中引入 .htaccess 文件
【发布时间】:2014-02-22 21:22:11
【问题描述】:

我最近开始研究 mvc。我的问题是css文件的识别。 当我添加行时

RewriteRule ^([^\/]*)/([^\/]*)$ index.php?page=$1&id=$2 [L,QSA]

到.htaccess 文件,另一个css 文件不知道。但是当把它改成

RewriteRule ^(.*)$ index.php?page=$1 [L,QSA]    

效果很好。

这是我的 .htaccess 文件详细信息

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.(css|pdf|gif|ico|jpg|js|png|swf|pdf|txt|php)$
RewriteRule ^([^\/]*)/([^\/]*)$ index.php?page=$1&id=$2 [L,QSA]
RewriteRule ^(.*)$ index.php?page=$1 [L,QSA]

我能做些什么来解决这个问题

【问题讨论】:

    标签: php css .htaccess


    【解决方案1】:

    试试这个..

    <IfModule mod_rewrite.c>
    RewriteEngine On
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
    
    </IfModule>
    

    【讨论】:

    • 它工作正常,但我想在地址方向上使用 2 步。喜欢 sample.com/page/12 并使用此模式。
    猜你喜欢
    • 2013-07-08
    • 1970-01-01
    • 2010-12-18
    • 2020-04-07
    • 2011-07-03
    • 1970-01-01
    • 2011-10-08
    • 1970-01-01
    • 2015-04-05
    相关资源
    最近更新 更多