在url中隐藏文件扩展名?
可以帮助我,我想隐藏在我的网站的网址中的文件扩展名。在url中隐藏文件扩展名?
这样一个例子是 http://www.mysite.com/home.php http://www.mysite.com/control.php
而是将显示为 http://www.mysite.com/home http://www.mysite.com/control
我一直在寻找到这一点,并发现这个代码,似乎隐藏文件扩展名的URL但现在我的链接不工作,即时通讯404错误。我认为我需要修改我的网站链接路径或类似的东西。
可有人告诉我什么,我需要做的拜托,这里是用我的.htaccess代码IM:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^/]+)/$ $1.php
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)*[^.]+\.php(\?[^\ ]*)?\ HTTP/
RewriteRule ^(([^/]+/)*[^.]+)\.php$ http://www.mysite.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ http://www.mysite.com/$1/ [R=301,L]
谷歌可以堆栈:)
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^([^/]+)/$ $1.html
# Forces a trailing slash to be added
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
http://eisabainyo.net/weblog/2007/08/19/removing-file-extension-via-htaccess/ 此外LOOKAT之前帮助 Making a rewriterule remove .php extension?
如果要隐藏所有扩展名(不只是.php,.html),请使用:
Options +FollowSymLinks +MultiViews
在httpd.conf
或的.htaccess
这不起作用,扩展仍然显示 – 2013-02-13 13:47:07
在.htaccess中 – 2013-02-13 13:57:48
您需要删除所有现有的首先规则并且仅尝试与上面的线。另外确保.htaccess确实启用。最后只需要在我们的Web服务器上为您提供经过充分测试的解决方案。 – anubhava 2013-02-13 14:35:16
这个代码犯规藏身,以往:( – 2013-02-13 13:45:00
如果你所说的任何扩展。 R /控制/它将加载controlled.html –
2013-02-13 13:47:19
我已经添加一个链接到像这样的前一个问题有一个gander – 2013-02-13 13:51:49