1

I've recently revamped my website so that it uses PHP for common elements. I then uploaded this .htaccess file:

RedirectMatch permanent ^(.*)\.htm(l?)$ $1.php 

to redirect requests for .htm or .html pages to the corresponding .php page. However, my host's stats manager, which is located in the /stats/ directory within my /public/ directory, uses .html pages, which now get redirected to .php pages, which don't exist and so return 404 errors. How do I set up .htaccess so as to not apply the redirect to pages within the /stats/ directory?

4

1 回答 1

0

尝试将重定向匹配 (mod_alias) 更改为使用 mod_rewrite,然后添加一个条件以排除所有/stats/请求:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/stats/
RewriteRule ^(.*)\.html?$ /$1.php [L,R=301]
于 2013-10-04T00:38:16.840 回答