重写指数当PHP aready删除重写、指数、aready、PHP

2023-09-02 01:02:12 作者:无眠

我有一个code在我的htaccess的,可以消除每一页.php为我的网站上。下面code是就我来了,但我真正想要的是,每一个页面名称后有一个斜线(仍然没有PHP) 那日指数(.PHP)的名字被完全删除。

Icouldn't找到的东西在有这两个结合互联网。我发现,在年底创建了一个斜杠code,但创造的许多问题与内部重定向。

时的这一切成为可能,如果是这样,怎么样?

在预先感谢,

 选项+了FollowSymLinks -MultiViews
RewriteEngine叙述上

#要外部重定向/dir/foo.php到/ DIR /富
的RewriteCond%{THE_REQUEST} ^ [AZ] {3,}  S([^。] +)。PHP [NC]
重写规则^%1 [R,L]

#在内部前进/ DIR /富到/dir/foo.php
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{} REQUEST_FILENAME -f .PHP
重写规则^(。*?)/?$ $ 1.PHP [L]
 

解决方案

尝试:

 选项+了FollowSymLinks -MultiViews
RewriteEngine叙述上

#要外部重定向/dir/foo.php到/ DIR /富
的RewriteCond%{THE_REQUEST} ^ [AZ] {3,}  S([^。] +)。PHP [NC]
重写规则^ /%1 / [R,L]

的RewriteCond%{THE_REQUEST} ^ [AZ] {3,}  S(。*)指标 .PHP [NC]
重写规则^ /%1 [R,L]

#在内部前进/ DIR /富到/dir/foo.php
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{REQUEST_URI} ^(。+?)/?$
的RewriteCond%{DOCUMENT_ROOT}%1.PHP -f
重写规则^(。*?)/?$ /$1.php [L]
 
生成 删除和重写 提高对话生成中人物属性一致性的三级生成框架

I have a code in my htaccess that removes the .php from every page on my site. The following code is as far as i came, but what i actually want is that every page has an slash after the name (still without php) and that de index(.php) name is completely removed.

Icouldn't find something on the internet having these two combined. I did find a code that created a slash at the end but that created many problems with internally redirecting.

Is all of this possible and if so, how?

Many thanks in advance,

Paul

Options +FollowSymLinks -MultiViews
RewriteEngine On

# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s([^.]+).php [NC]
RewriteRule ^ %1 [R,L]

# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L]

解决方案

Try:

Options +FollowSymLinks -MultiViews
RewriteEngine On

# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s([^.]+).php [NC]
RewriteRule ^ /%1/ [R,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s(.*)index.php [NC]
RewriteRule ^ /%1 [R,L]

# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^(.+?)/?$
RewriteCond %{DOCUMENT_ROOT}%1.php -f
RewriteRule ^(.*?)/?$ /$1.php [L]