2

こんにちは、私は自分の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
4

1 に答える 1

2

上記の私の仮定のコメントに基づいて、あなたは試してみるべきです

# This rewrites all incoming request to *.php or *.html to remove the extension. NOte the R=301 which give header indicating to the browser/spider that the resource has been relocated. The L indicates this is the last rule to be processed before sending headers to browser (which will start the process all over again) This rule MUST be first
RewriteRule ^(.*)\.(php|html)$ /$1 [R=301,L]

#This set of conditions is only applicable if the request is not a directory, is not itself a file, and has a similarly name file with .php extension.  Here we do not perform a URL rewrite (i.e. [R]), but just pass this to the .php file as the last htaccess rule executed.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ /$1.php [L]
于 2012-07-24T19:22:57.277 に答える