关于htaccess,你有点慢,这让我整天都很头疼。我不确定我做错了什么,但我尝试解决这个问题的所有组合都出错了。
我希望将index.php设置为文件夹的默认索引页面,并将网站的主页重定向到formacompany.com/en我不希望文件末尾有.php。
以下是我的代码,我希望www.example.com/ru在目录中显示index.php文件,但不希望网址为www.example.com/ru/index
DirectoryIndex index.php
ErrorDocument 404 /404.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
redirect 301 /admin/ http://www.example.com/_admin/index.php
redirect 301 /payment https://www.example.com/en/secure/ccpayment
redirect 301 http://www.formacompany.com http://www.formacompany.com/en/index
当我访问example.com/ru时,我将此作为网址和页面错误:
答案 0 :(得分:0)
不要将mod_rewrite
规则与mod_alias
个规则混合,并在内部重写规则之前保留重定向规则:
DirectoryIndex index.php
ErrorDocument 404 /404.php
RewriteEngine On
RewriteRule ^admin/?$ http://www.example.com/_admin/index.php [L,R=302]
RewriteRule ^payment/?$ https://www.example.com/en/secure/ccpayment [L,R=302]
RewriteRule ^/?$ http://www.formacompany.com/en/index [L,R=302]
# To internally forward /dir/file to /dir/file.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC]
RewriteRule ^(.+?)/?$ /$1.php [L]