重写指数当PHP aready删除 [英] Rewrite index when php is aready removed

查看:92
本文介绍了重写指数当PHP aready删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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]

这篇关于重写指数当PHP aready删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆