嘿,
我正在尝试使用apache mod_rewrite使我的网址更漂亮。
此刻,我的网址如下:
https://example.com/sites/profil.php
https://example.com/sites/work.php
我希望它看起来像这样:
如何覆盖“站点文件夹” ,所以没有,并且可以删除.php扩展名 ?
那是我的apache配置的样子:
<VirtualHost example.com>
DocumentRoot /var/www/example.com/html
ServerName example.com
ServerAlias www.example.com
<Directory "/var/www/example.com/html">
allow from all
Options None
Require all granted
</Directory>
RewriteEngine on
RewriteCond %{SERVER_NAME} =example.com [OR]
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
文件更改后是否需要编辑链接?
答案 0 :(得分:0)
这是您的mod重写规则
# Rewrite --- https://example.com/sites/profil.php => https://example.com/profil
RewriteRule ^profil$ sites/profil\.php [NC,L]
# Rewrite --- https://example.com/sites/work.php => https://example.com/work
RewriteRule ^work$ sites/work\.php [NC,L]
在正确的位置将其输入到您的.htaccess
中,然后尝试一下。
答案 1 :(得分:0)
while