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]