我已經設置了一些301重定向在我的.htaccess文件...對於不存在的文件。他們的確在重定向,但增加了一個查詢。例如:301重定向加入?頁=
在我的htaccess文件中使用下面的一個重定向: 如果我輸入example.com/about-example.php它應該將我重定向到example.com/about-example.html,它的種類是,但它需要我這個加?頁面example.com/about-example.html?page=about-example.php =(重定向)和MOZ是看到重定向的頁面查詢末爲重複的原始頁面。
這裏是我的htaccess的樣子......(改變了很多例子/ XYZ)
Options -Indexes +FollowSymLinks
RewriteEngine on
RewriteBase/
# Remove "www."
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# Redirect any requests for html files to index
RewriteRule ^(.+)\.html index.php?page=$1 [L]
# Rewrite any request for subdirectories to index
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?page=$1 [L,QSA]
## SITE REFERRER BANNING
RewriteCond %{HTTP_REFERER} ^http://([^.]+\.)*example\.net/ [NC,OR]
## EXPIRES CACHING ##
# 6 month for most static assets
<filesMatch ".(jpg|jpeg|png|gif|gs|ico)$">
Header set Cache-Control "max-age=1576800, public"
</filesMatch>
# 1 month for most static assets
<filesMatch ".(css|js)$">
Header set Cache-Control "max-age=2628000, public"
</filesMatch>
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 month"
# CSS
ExpiresByType text/css "access plus 1 year"
# Data interchange
ExpiresByType application/json "access plus 0 seconds"
ExpiresByType application/xml "access plus 0 seconds"
ExpiresByType text/xml "access plus 0 seconds"
# Favicon (cannot be renamed!)
ExpiresByType image/x-icon "access plus 1 week"
# HTML components (HTCs)
ExpiresByType text/x-component "access plus 1 month"
# HTML
ExpiresByType text/html "access plus 0 seconds"
# JavaScript
ExpiresByType application/javascript "access plus 1 year"
# Manifest files
ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds"
ExpiresByType text/cache-manifest "access plus 0 seconds"
# Media
ExpiresByType audio/ogg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType video/mp4 "access plus 1 month"
ExpiresByType video/ogg "access plus 1 month"
ExpiresByType video/webm "access plus 1 month"
# Web feeds
ExpiresByType application/atom+xml "access plus 1 hour"
ExpiresByType application/rss+xml "access plus 1 hour"
# Web fonts
ExpiresByType application/font-woff2 "access plus 1 month"
ExpiresByType application/font-woff "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
ExpiresByType application/x-font-ttf "access plus 1 month"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
</IfModule>
Redirect 301 /about-example.php http://example.com/about-example.html
Redirect 301 /vacation-faq.php http://example.com/faqs.html
Redirect 301 /3d-tour.html http://example.com/plans.html
Redirect 301 /images/cool/04.jpg http://example.com/gallery.html
我失去了一個命令,或者是放錯了地方的重定向?我已經嘗試了重寫規則,redirectmatch ...以及其他一些結果相同或500內部錯誤..(編輯)我也搞砸了重定向的位置無濟於事。
我不完全理解你的問題,但你有一個特定的重寫來做這個'RewriteRule ^(。+)\。html index.php?page = $ 1 [L]' –
我會編輯我的主要評論到進一步解釋。 – dhath