我在godaddy网络服务器上托管我的网站,我尝试使用htaccess文件,但它没有工作请告诉我解决方案是什么,并帮助我使其工作
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]
答案 0 :(得分:0)
使用以下代码更改它。
RewriteEngine on
RewriteCond %{HTTP_HOST} ^YOURSITE\.com\\index$ [OR]
RewriteCond %{HTTP_HOST} ^www\.YOURSITE\.com\\index$
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^/?$ "http\:\/\/www\.YOURSITE\.com\/" [R=301,L]
# Turn mod_rewrite on
Options +FollowSymLinks -MultiViews
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [QSA,L]
# Redirect /product?pid=2 to /product/2
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+product\?pid=([^&\s]+) [NC]
RewriteRule ^ /product/%1? [R=302,L]