thinphp apache url重寫有關問題

來源:互聯網
上載者:User
thinphp apache url重寫問題
例如:http://www.xxxx.com/index.php/Index/index/n/50
把這個url重寫成:
http://www.xxxx.com/50
而不影響其他模組
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] 這樣只是把index.php去掉了,
訪問首頁的時候需要http://www.xxxx.com/50這樣的效果
其他的還是:http://www.iwebo.dev/Setting/index
只是去掉index.php

寫成這樣:
RewriteRule ^(.*)$ index.php/Index/index/n/$1 [QSA,PT,L]
會影響全部模組的訪問
在糾結,還請各位幫忙看看...

------解決方案--------------------
Options +FollowSymLinks +SymLinksIfOwnerMatch

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*)$ index.php/$1 [L]


# Turn on these settings to get A in yslow. :)
#
# ExpiresActive On
# ExpiresByType image/gif A2592000
# ExpiresByType image/jpeg A2592000
# ExpiresByType image/png A2592000
# ExpiresByType image/x-icon A2592000
# ExpiresByType application/javascript A2592000
# ExpiresByType application/x-shockwave-flash A2592000
# ExpiresByType text/css A604800
#
#
#
# AddOutputFilterByType DEFLATE text/html text/css application/javascript
#
#
# FileEtag none
------解決方案--------------------
通常的URL裡面含有index.php,為了達到更好的SEO效果可能需要去掉URL裡面的index.php ,通過URL重寫的方式可以達到這種效果,通常需要伺服器開啟URL_REWRITE模組才能支援。

下面是Apache的配置過程,可以參考下:

1、httpd.conf設定檔中載入了mod_rewrite.so模組

2、AllowOverride None 將None改為 All

3、確保URL_MODEL設定為2

4、把.htaccess檔案放到入口檔案的同級目錄下



RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

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


  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.