我已经使用.htaccess更改了根文件夹,但我也需要隐藏.html/.php扩展名,这是我遇到问题的地方。我找到了隐藏扩展名的替代方法,但并不像我想的那么简单。以下是我迄今所做>>>.htaccess更改根文件夹并隐藏.html/.php扩展名
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?cornellbond.co.uk$
RewriteCond %{REQUEST_URI} !^/liveSite/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /liveSite/$1
RewriteCond %{HTTP_HOST} ^(www.)?cornellbond.co.uk$
RewriteRule ^(/)?$ liveSite/index.html [L]
这工作,但我下面的代码添加到它的一切停止工作。
然后我想要隐藏.html/.php扩展名我在这里找到了这个代码SOF,所以结合了这两个,所有我得到的是错误。
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f # if the requested URL is not a file that exists
RewriteCond %{REQUEST_FILENAME} !-d # and it isn't a directory that exists either
RewriteCond %{REQUEST_FILENAME}\.html -f # but when you put ".html" on the end it is a file that exists
RewriteRule ^(.+)$ $1\.html [QSA] # then serve that file
</IfModule>
所以我的代码看起来像这样一起其中>>>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?cornellbond.co.uk$
RewriteCond %{REQUEST_URI} !^/liveSite/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /liveSite/$1
RewriteCond %{HTTP_HOST} ^(www.)?cornellbond.co.uk$
RewriteRule ^(/)?$ liveSite/index.html [L]
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.+)$ $1\.html [QSA]
</IfModule>
如果我能得到一个变通为了这个,我将不胜感激。我说了这一切新的给我,我还在学习= P再次感谢
如果你只想隐藏扩展名可能看
嘿mabarroso,我不明白你的答案,是否有可能你可以把它分解下来让我工作,谢谢;) –