本文介绍了我如何使用的.htaccess隐藏的.php URL扩展?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要的东西,把我的的.htaccess 文件,将隐藏的.php 文件扩展我的PHP文件,因此要www.example/dir/somepage~~V会告诉他们www.example/dir/somepage.php。
对此有任何可行的解决方案?我的网站使用HTTPS,如果在所有重要的。
这是我的.htaccess的时刻:
RewriteEngine叙述上 的RewriteCond%{} SERVER_PORT 80 重写规则^(。*)$ www.example/$1 [R,L] ErrorDocument的404 /error/404.php 的RewriteCond%{} REQUEST_FILENAME -f .PHP 的RewriteCond%{REQUEST_URI}!/ $ 重写规则(。*)$ 1 \ .PHP [L]解决方案
使用这种code在你的.htaccess下DOCUMENT_ROOT:
选项+了FollowSymLinks -MultiViews #开启mod_rewrite的上 RewriteEngine叙述上 的RewriteBase / #要外部重定向/dir/foo.php到/ DIR /富 的RewriteCond%{THE_REQUEST} ^ [AZ] {3,} \ S([^。] +)\。PHP [NC] 重写规则^%1 [R,L,NC] ##在内部重定向/ DIR /富到/dir/foo.php 的RewriteCond%{} REQUEST_FILENAME -f .PHP [NC] 重写规则^%{REQUEST_URI}的.php [L]I want something to put in my .htaccess file that will hide the .php file extension for my php files, so going to www.example/dir/somepage would show them www.example/dir/somepage.php.
Is there any working solution for this? My site uses HTTPS, if that matters at all.
This is my .htaccess at the moment:
RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ www.example/$1 [R,L] ErrorDocument 404 /error/404.php RewriteCond %{REQUEST_FILENAME}.php -f RewriteCond %{REQUEST_URI} !/$ RewriteRule (.*) $1\.php [L]解决方案
Use this code in your .htaccess under DOCUMENT_ROOT:
Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / # To externally redirect /dir/foo.php to /dir/foo RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC] RewriteRule ^ %1 [R,L,NC] ## To internally redirect /dir/foo to /dir/foo.php RewriteCond %{REQUEST_FILENAME}.php -f [NC] RewriteRule ^ %{REQUEST_URI}.php [L]
更多推荐
我如何使用的.htaccess隐藏的.php URL扩展?
发布评论