将.htaccess文件和localhost变为空
Here is my URL for my website. http://localhost/GASS-2110/alarm-system/overview.php
.I wanted to remove the .php extension so that the URL become like this;http://localhost/GASS-2110/alarm-system/overview
. I paste the .htaccess file in my root directory, run the localhost, and i find its empty! i dont know why is this happening and i am not sure what did i do wrong. I believed that i need to configure something which i do not know what it is.What am i suppose to do? I am a beginner so please dont be harsh with me. where should i call the .htaccess file?
Here is what i put in my .htaccess file.
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]
p/s: sorry for my bad english
这是我网站的网址。 这是我放在.htaccess文件中的内容。 p>
p / s:抱歉我的英文不好 p>
div> http://localhost/GASS-2110/alarm-system/overview.php code>。我想删除.php扩展名,以便URL变成这样;
http:// localhost / GASS-2110 /报警系统/概述代码>。 我将.htaccess文件粘贴到我的根目录中,运行localhost,我发现它是空的! 我不知道为什么会这样,我不知道我做错了什么。 我相信我需要配置一些我不知道它是什么的东西。我想做什么? 我是初学者所以请不要对我很苛刻。 我应该在哪里调用.htaccess文件? p>
Options + FollowSymLinks -MultiViews
#转动mod_rewrite on
RewriteEngine On
RewriteBase /
#将外部重定向/dir/foo.php外部重定向到/ dir / foo
RewriteCond%{THE_REQUEST} ^ [AZ] { 3,} \ s([^。] +)\ .php [NC]
RewriteRule ^%1 [R,L,NC]
##内部重定向/ dir / foo到/ dir / foo .php
RewriteCond%{REQUEST_FILENAME} .php -f [NC]
RewriteRule ^%{REQUEST_URI} .php [L]
code> pre>
When a change in .htaccess
results in the page being empty this means there was an error parsing the file, most frequently because of typos or referring to a module that's not loaded. You can check the problem in the Apache error log - check the ErrorLog
directive in the vhost config for its location, otherwise it's in the general Apache error log (on Linux usually /var/log/apache/error.log
).
If the error is something akin to Unknown option RewriteEngine
you haven't enabled mod_rewrite
correctly. On Debian/Ubuntu systems you can fix this by running a2enmod rewrite
, for other systems the instructions could vary.