使用.htaccess在windows上重写URL。

时间:2021-01-09 11:09:50

I have have turned mod_rewrite on in a windows machine and created .htaccess in the root directory of my website, now after i wrote FAIL in it it gave me an internal server error then i replaced the code with this

我已经在windows机器上打开了mod_rewrite,在我的网站的根目录中创建了。htaccess,在我写了失败之后,它给了我一个内部服务器错误,然后我用这个替换了代码。

Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ /$1.php [L,QSA]

I am trying to remove .php and make friendly URLs, when i am tring to load index without using .php it is giving me a 404 Not found error i have restarted the wamp server several times and the same problem. Can somebody help me here.

我正在尝试删除。php,并创建友好的url,当我在不使用.php的情况下加载索引时,它给了我一个404 Not found错误,我已经多次重启wamp服务器,同样的问题。有人能帮我一下吗?

Thanks in advance

谢谢提前

2 个解决方案

#1


4  

I have changed the .htaccess to this

我已经改变了。htaccess。

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

and it worked just in case somebody faces the same problem

如果有人遇到同样的问题,它就会起作用。

#2


0  

Remove the line RewriteCond %{REQUEST_FILENAME}.php -f. It is unnecessary.

删除行RewriteCond %{REQUEST_FILENAME}。php - f。这是不必要的。

#1


4  

I have changed the .htaccess to this

我已经改变了。htaccess。

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

and it worked just in case somebody faces the same problem

如果有人遇到同样的问题,它就会起作用。

#2


0  

Remove the line RewriteCond %{REQUEST_FILENAME}.php -f. It is unnecessary.

删除行RewriteCond %{REQUEST_FILENAME}。php - f。这是不必要的。