您好,我正在尝试设置我的 URL 设置,并且我已经提出了一些要求,但我的最后一个问题如下:
例如,如果用户尝试访问site.com/foo.php
,他们应该被重定向到site.com/foo
;相反,如果用户输入site.com/foo
,他们不应该被重定向,但请求的页面应该是site.com/foo.php
.
这是我的.htacces:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^(.*)\.html$
RewriteRule ^.*\.html$ %1.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^/]+)/$ $1.php
AddType application/x-httpd-php .htm .html
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
Redirect /anmeldung http://www.site.com/register
Redirect /anmeldung.htm http://www.site.com/register
Redirect /anmeldung.html http://www.site.com/register
Redirect /anmeldung.php http://www.site.com/register
Redirect /registierung http://www.site.com/register
Redirect /registierung.htm http://www.site.com/register
Redirect /registierung.html http://www.site.com/register
Redirect /registierung.php http://www.site.com/register
Redirect /register.htm http://www.site.com/register
Redirect /register.html http://www.site.com/register
如果有人可以帮助我,我将不胜感激。非常感谢。
更新:
完整的 htaccess:
RewriteEngine On
EewriteRule ^(.*)\.(php|html)$ /$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ /$1.php [L]
Redirect /anmeldung http://www.site.com/register
Redirect /anmeldung.htm http://www.site.com/register
Redirect /anmeldung.html http://www.site.com/register
Redirect /anmeldung.php http://www.site.com/register
Redirect /registierung http://www.site.com/register
Redirect /registierung.htm http://www.site.com/register
Redirect /registierung.html http://www.site.com/register
Redirect /registierung.php http://www.site.com/register