我試圖將我的重寫規則添加到httpd.conf
並禁用.htaccess
以提高服務器性能。出於某種原因,我所嘗試過的一切都不起作用。httpd.conf中的mod_rewrite規則不起作用
在我的主httpd.conf
我已禁用所有AllowOverride
實例將它們設置爲無。
我有它的虛擬主機塊中的每個站點
Include "etc/apache2/conf.d/site.com/rewrite.conf"
則包含文件中rewrite.conf
我有這樣的事情:
<Directory "/home/shopmobilephones/public_html">
RewriteEngine On
ServerSignature off
# HTTP > HTTPS #########################################################################
RewriteCond %{HTTPS} off
RewriteRule (.*) https://shopmobilephones.co.uk%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} ^/www.shopmobilephones.co.uk [NC]
RewriteRule (.*) https://shopmobilephones.co.uk%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* ? [F,L]
RewriteRule ^/mobiles/deals/cash-back /cashback.php [L]
RewriteRule ^/mobiles/deals/cheap-mobile-phones /cheapmobilephones.php [L]
RewriteRule ^/mobiles/deals/clearance-deals /clearance.php [L]
RewriteRule ^/mobiles/deals/contracts /contractphones.php [L]
RewriteRule ^/mobiles/deals/12-months-free-line-rental /12month.php [L]
RewriteRule ^/mobiles/deals/top-deals /dailydeals.php [L]
RewriteRule ^/mobiles/deals/free-phones /freephones.php [L]
RewriteRule ^/mobiles/deals/new-mobile-phones /ladeals.php [L]
RewriteRule ^/mobiles/deals/sim-free-phones /simfree.php [L]
RewriteRule ^/mobiles/colours/(.*) /colours.php?colour=$1 [L]
RewriteRule ^/mobiles/(.*)/contract-deals /dealsnew.php?slug=$1&deal-type=1&device-type=Phone&network=all [L]
RewriteRule ^/mobiles/(.*)/upgrades /dealsnew.php?slug=$1&deal-type=2&device-type=Phone&network=all [L]
RewriteRule ^/mobiles/(.*)/contract-deals/(.*) /dealsnew.php?slug=$1&deal-type=1&device-type=Phone&NETWORK=$2 [L]
</Directory>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
# php -- BEGIN cPanel-generated handler, do not edit
# Set the 「ea-php56」 package as the default 「PHP」 programming language.
<IfModule mime_module>
AddType application/x-httpd-ea-php56 .php .php5 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
我曾嘗試加入RewriteBase /和刪除所有前綴/這不起作用我也從目錄塊中取出了這些不起作用的規則,我甚至在主要httpd.conf中添加了內外目錄塊中的規則,但沒有任何作用,我在哪裏出錯了?
什麼是Apache版本? –
「沒有任何作用」的說法是一個非常普遍而廣泛的說法,我懷疑這是真的。請更具體地說_exactly_不起作用。最好的辦法是提供具體的(匿名)請求URL,您的期望和實際結果。請將這些細節添加到問題中,而不是在評論中。 – arkascha