문제

I've just noticed that I can load pages within and without index.php in the URL.

So, I can load these URLs:

  • example.com
  • example.com/index.php (I don't want this)
  • example.com/product.html
  • example.com/index.php/product.html (I don't want this)

I'm running M2+Apache, and would like to know how to stop this from happening.digital

도움이 되었습니까?

해결책

You can remove all the index.php's from your frontend URLs, by adding the following rewrite rules to your apache config (.htaccess):

RewriteEngine on
RewriteCond %{REQUEST_URI} !/admin/
RewriteRule ^index\.php/(.+)$ /$1 [R,L]
RewriteRule ^index\.php/?$ / [R,L]

1st line: turns on rewrite engine

2nd line: makes sure to leave index.php alone for all admin URLs

3rd line: removes index.php from the URL and redirects to that version ex. example.com/index.php/product.html becomes example.com/product.html

4th line: handles redirecting example.com/index.php to example.com/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top