奇怪的网址与.htaccess

时间:2014-07-09 10:13:06

标签: regex apache .htaccess mod-rewrite

我有一个.htaccess文件设置来删除.php并添加一个尾部斜杠和各种重定向等。虽然大多数URL完美地工作了几个3-4正在提供给浏览器确定但是非常奇怪格式。

即正确的网址应为: http://www.eafs.eu/contractor-accountants/changing-accountants/但它正在向浏览器提供多个尾部斜杠。 http://www.eafs.eu/contractor-accountants////////////////////changing-accountants/

有人能说明为什么会这样吗?我已经添加了.htaccess文件的完整副本,如果这有帮助......

# ReWrite Rules
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /

# Remove .php extension
RewriteCond %{THE_REQUEST} ^GET\ /[^?\s]+\.php
RewriteRule (.*)\.php$ /$1/ [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/(.+)/$
RewriteCond %{DOCUMENT_ROOT}/%1.php -f
RewriteRule ^(.*)/$ $1.php [L]

# Force trailing slash
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule .*[^/]$ $0/ [L,R=301]
</IfModule>

#  SEO - Redirects
redirect 301 /table/european-payroll/ http://www.eafs.eu
redirect 301 /table/landing-pages/ http://www.eafs.eu
redirect 301 /table/working-in-europe/ http://www.eafs.eu
redirect 301 /table/uk-umbrella-services/ http://www.eafs.eu
redirect 301 /table/ltd-company-contractors/ http://www.eafs.eu
redirect 301 /table/contracting-in-europe/ http://www.eafs.eu
redirect 301 /table/uk-specialist-services/ http://www.eafs.eu
redirect 301 /table/uk-limited-company/ http://www.eafs.eu
redirect 301 /table/uk-accountancy-services/ http://www.eafs.eu
redirect 301 /table/ltd-company-contractors/Page-2 http://www.eafs.eu
redirect 301 /table/uk-limited-company/Page-2 http://www.eafs.eu
redirect 301 /table/euro-accountancy-a-finance-solutions/ http://www.eafs.eu
redirect 301 /table/ltd-company-contractors/Page-3 http://www.eafs.eu
redirect 301 /table/working-in-europe/Page-2 http://www.eafs.eu
redirect 301 /ltd-company-contractors/s660-settlements-legislation http://www.eafs.eu
redirect 301 /uk-umbrella-services/our-umbrella-services http://www.eafs.eu
redirect 301 /uk-specialist-services/other-accountancy-services http://www.eafs.eu
redirect 301 /uk-accountancy-services/uk-accountancy-services http://www.eafs.eu
redirect 301 /ltd-company-contractors/agency-workers-regulations http://www.eafs.eu
redirect 301 /ltd-company-contractors/tax-deductable-expenses http://www.eafs.eu
redirect 301 /ltd-company-contractors/insurance-for-contractors http://www.eafs.eu
redirect 301 /ltd-company-contractors/flat-rate-vat-scheme http://www.eafs.eu
redirect 301 /ltd-company-contractors/vat-paye-corporation-tax http://www.eafs.eu
redirect 301 /table/working-in-europe/feed/rss/Page-2 http://www.eafs.eu
redirect 301 /table/sh404sef-custom-content/feed/rss http://www.eafs.eu
redirect 301 /table/uk-limited-company/feed/atom/Page-2 http://www.eafs.eu
redirect 301 /table/ltd-company-contractors/feed/rss/Page-2 http://www.eafs.eu
redirect 301 /table/euro-accountancy-a-finance-solutions/feed/rss http://www.eafs.eu
redirect 301 /table/uk-specialist-services/feed/rss http://www.eafs.eu
redirect 301 /contracting-in-europe/contracting-in-europe http://www.eafs.eu
redirect 301 /ltd-company-contractors/contractor-accountants http://www.eafs.eu
# redirect 301 /contractor-accountants/limited-company-contractors http://www.eafs.eu

# Joomla to New Website - Redirects
redirect 301 /uk-accountancy-services http://www.eafs.eu/company-formations/
redirect 301 /uk-accountancy-services/sole-trader http://www.eafs.eu/company-formations/
redirect 301 /uk-accountancy-services/partnership http://www.eafs.eu/company-formations/
redirect 301 /uk-accountancy-services/uk-limited-company-formations http://www.eafs.eu/company-formations/limited-company/
redirect 301 /other-accountancy-services http://www.eafs.eu/contractor-services/
redirect 301 /uk-specialist-services/tax-planning-services http://www.eafs.eu
redirect 301 /uk-specialist-services/vat-returns-service http://www.eafs.eu/contractor-accountants/vat-returns/
redirect 301 /uk-specialist-services/management-accounts http://www.eafs.eu
redirect 301 /uk-specialist-services/construction-industry-scheme http://www.eafs.eu
redirect 301 /uk-specialist-services/payroll-services http://www.eafs.eu
redirect 301 /uk-specialist-services/sage-training http://www.eafs.eu
redirect 301 /our-umbrella-services http://www.eafs.eu
redirect 301 /uk-umbrella-services/uk-umbrella-solution http://www.eafs.eu
redirect 301 /uk-umbrella-services/getting-started-guide http://www.eafs.eu
redirect 301 /uk-umbrella-services/benefits-of-a-eafs-umbrella http://www.eafs.eu
redirect 301 /uk-umbrella-services/childcare-voucher-scheme http://www.eafs.eu
redirect 301 /uk-umbrella-services/umbrella-v-limited http://www.eafs.eu
redirect 301 /uk-umbrella-services/umbrella-faq http://www.eafs.eu
# redirect 301 /contractor-accountants http://www.eafs.eu/contractor-accountants/
# redirect 301 /limited-company-formation http://www.eafs.eu/company-formations/limited-company/
# redirect 301 /contractor-accountants/why-choose-eafs http://www.eafs.eu/contractor-accountants/why-choose-eafs/
# redirect 301 /contractor-accountants/limited-company-services http://www.eafs.eu/contractor-accountants/limited-company-services/
# redirect 301 /contractor-accountants/limited-v-umbrella http://www.eafs.eu/contractor-accountants/limited-versus-umbrella/
# redirect 301 /contractor-accountants/limited-company-faq http://www.eafs.eu/contractor-accountants/limited-company-faq/
# redirect 301 /contractor-accountants/vat-paye-corporation-tax http://www.eafs.eu/contractor-accountants/pay-as-you-earn/
# redirect 301 /contractor-accountants/flat-rate-vat-scheme http://www.eafs.eu/contractor-accountants/flat-rate-scheme/
# redirect 301 /contractor-accountants/ir35-explained http://www.eafs.eu/contractor-accountants/ir35-explained/
# redirect 301 /contractor-accountants/agency-workers-regulations http://www.eafs.eu/contractor-accountants/agency-workers-regulations/
# redirect 301 /contractor-accountants/s660-settlements-legislation http://www.eafs.eu/contractor-accountants/s660-settlements/
# redirect 301 /contractor-accountants/tax-deductable-expenses http://www.eafs.eu/contractor-accountants/business-expenses/
# redirect 301 /contractor-accountants/business-bank-account http://www.eafs.eu/contractor-services/business-bank-account/
# redirect 301 /contractor-accountants/insurance-for-contractors http://www.eafs.eu/contractor-services/insurance-for-contractors/
# redirect 301 /contractor-accountants/changing-accountants http://www.eafs.eu/contractor-accountants/changing-accountants/
# redirect 301 /contractor-accountants/mortgages-for-contractors http://www.eafs.eu/contractor-services/mortgages-for-contractors/
# redirect 301 /contracting-in-europe http://www.eafs.eu/contracting-europe/
redirect 301 /contracting-in-europe/contractor-support http://www.eafs.eu/faq-tools/
redirect 301 /contracting-in-europe/agency-support http://www.eafs.eu/faq-tools/agency-support/
redirect 301 /contracting-in-europe/customer-satisfaction http://www.eafs.eu/faq-tools/
redirect 301 /contracting-in-europe/contracting-in-europe-faq http://www.eafs.eu/faq-tools/
redirect 301 /european-payroll http://www.eafs.eu/contracting-europe/
redirect 301 /european-payroll/dutch-payroll-services http://www.eafs.eu/contracting-europe/working-in-netherlands/dutch-payroll/
redirect 301 /european-payroll/dutch-umbrella-bv http://www.eafs.eu/contracting-europe/working-in-netherlands/dutch-bv/
redirect 301 /european-payroll/german-payroll-services http://www.eafs.eu/contracting-europe/working-in-germany/german-payroll/
redirect 301 /european-payroll/belgium-payroll-services http://www.eafs.eu/contracting-europe/working-in-belgium/belgium-payroll/
redirect 301 /european-payroll/austrian-payroll-services http://www.eafs.eu/contracting-europe/
redirect 301 /european-payroll/czech-republic-payroll-services http://www.eafs.eu/contracting-europe/
redirect 301 /european-payroll/italian-payroll-services http://www.eafs.eu/contracting-europe/working-in-italy/italian-payroll/
redirect 301 /european-payroll/luxembourg-payroll-services http://www.eafs.eu/contracting-europe/working-in-luxembourg/luxembourg-payroll/
redirect 301 /european-payroll/swedish-payroll-services http://www.eafs.eu/contracting-europe/
redirect 301 /30-percent-tax-rule-holland http://www.eafs.eu/contracting-europe/working-in-netherlands/30-ruling/
redirect 301 /fixed-rate-accounts-fees http://www.eafs.eu/contractor-accountants/
redirect 301 /maximun-income-retention http://www.eafs.eu/contractor-accountants/
redirect 301 /payroll-for-contractors http://www.eafs.eu/contractor-accountants/
redirect 301 /working-in-europe/working-in-austria http://www.eafs.eu/contracting-europe/
redirect 301 /working-in-europe/working-in-belgium http://www.eafs.eu/contracting-europe/working-in-belgium/
redirect 301 /working-in-europe/working-in-czech-republic http://www.eafs.eu/contracting-europe/
redirect 301 /working-in-europe/working-in-denmark http://www.eafs.eu/contracting-europe/
redirect 301 /working-in-europe/working-in-france http://www.eafs.eu/contracting-europe/
redirect 301 /working-in-europe/working-in-germany http://www.eafs.eu/contracting-europe/working-in-germany/
redirect 301 /working-in-europe/working-in-italy http://www.eafs.eu/contracting-europe/working-in-italy/
redirect 301 /working-in-europe/working-in-luxembourg http://www.eafs.eu/contracting-europe/working-in-luxembourg/
redirect 301 /working-in-europe/working-in-netherlands http://www.eafs.eu/contracting-europe/working-in-netherlands/
redirect 301 /working-in-europe/working-in-poland http://www.eafs.eu/contracting-europe/
redirect 301 /working-in-europe/working-in-spain http://www.eafs.eu/contracting-europe/
redirect 301 /working-in-europe/working-in-sweden http://www.eafs.eu/contracting-europe/
redirect 301 /working-in-europe/working-in-britain http://www.eafs.eu/contracting-europe/
redirect 301 /partner-links http://www.eafs.eu
redirect 301 /forms-a-calculators/financial-calculators http://www.eafs.eu
redirect 301 /uk-limited-company/accountancy-package-bronze http://www.eafs.eu
redirect 301 /uk-limited-company/accountancy-package-silver http://www.eafs.eu
redirect 301 /uk-limited-company/accountancy-package-gold http://www.eafs.eu
redirect 301 /uk-limited-company/accountancy-package-construction http://www.eafs.eu
redirect 301 /uk-limited-company/accountancy-package-bespoke http://www.eafs.eu
redirect 301 /uk-limited-company/company-formation-basic http://www.eafs.eu
redirect 301 /uk-limited-company/company-formation-standard http://www.eafs.eu
redirect 301 /uk-limited-company/company-formation-professional http://www.eafs.eu
redirect 301 /calculators/VAT_Calculator.php http://www.eafs.eu
redirect 301 /calculators/VAT_Calculator_Results.php http://www.eafs.eu
redirect 301 /calculators/Dutch_Payroll_Form.php http://www.eafs.eu
redirect 301 /calculators/Corporation_Tax_Form.php http://www.eafs.eu
redirect 301 /calculators/Dutch_Payroll_Results.php http://www.eafs.eu
redirect 301 /calculators/Inheritance_Tax_Form.php http://www.eafs.eu
redirect 301 /calculators/Inheritance_Tax_Results.php http://www.eafs.eu
redirect 301 /calculators/Stamp_Duty_Form.php http://www.eafs.eu
redirect 301 /calculators/Stamp_Duty_Results.php http://www.eafs.eu
redirect 301 /calculators/Loan_Repayment_Form.php http://www.eafs.eu
redirect 301 /calculators/Gross_Profit_Margin_Results.php http://www.eafs.eu
redirect 301 /calculators/Loan_Repayment_Form.php http://www.eafs.eu
redirect 301 /calculators/Loan_Repayment_Results.php http://www.eafs.eu
redirect 301 /calculators/Gross_Profit_Margin_Results.php http://www.eafs.eu
redirect 301 /calculators/Gross_Profit_Margin_Results.php http://www.eafs.eu
redirect 301 /calculators/Gross_Profit_Form.php http://www.eafs.eu

#Compression
<ifModule mod_gzip.c>
  mod_gzip_on Yes
  mod_gzip_dechunk Yes
  mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
  mod_gzip_item_include handler ^cgi-script$
  mod_gzip_item_include mime ^text/.*
  mod_gzip_item_include mime ^application/x-javascript.*
  mod_gzip_item_exclude mime ^image/.*
  mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

#Expiry Headers
<ifModule mod_expires.c>
  ExpiresActive On
  ExpiresDefault "access plus 1 seconds"
  ExpiresByType text/html "access plus 1 seconds"
  ExpiresByType image/gif "access plus 2592000 seconds"
  ExpiresByType image/jpeg "access plus 2592000 seconds"
  ExpiresByType image/png "access plus 2592000 seconds"
  ExpiresByType text/css "access plus 604800 seconds"
  ExpiresByType text/javascript "access plus 216000 seconds"
  ExpiresByType application/x-javascript "access plus 216000 seconds"
</ifModule>

#Headers
<ifModule mod_headers.c>
  <filesMatch "\\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$">
    Header set Cache-Control "max-age=2592000, public"
  </filesMatch>
  <filesMatch "\\.(css)$">
    Header set Cache-Control "max-age=604800, public"
  </filesMatch>
  <filesMatch "\\.(js)$">
    Header set Cache-Control "max-age=216000, private"
  </filesMatch>
  <filesMatch "\\.(xml|txt)$">
    Header set Cache-Control "max-age=216000, public, must-revalidate"
  </filesMatch>
  <filesMatch "\\.(html|htm|php)$">
    Header set Cache-Control "max-age=600, private, must-revalidate"
  </filesMatch>
</ifModule>

1 个答案:

答案 0 :(得分:1)

尝试更改规则的顺序,并在内部重写规则之前保留R规则:

RewriteEngine on
RewriteBase /

# Remove .php extension
RewriteCond %{THE_REQUEST} ^GET\ /[^?\s]+\.php
RewriteRule (.*)\.php$ /$1/ [L,R=301]

# Force trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule [^/]$ $0/ [L,R=301,NE]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+?)/$ $1.php [L]