htaccess中的自定义链接,无需更改<a href="">?

时间:2019-04-15 12:19:13

标签: html .htaccess url hyperlink href

I got this: <a href="contact.php">

This is just an example but let's try to solve on this.

I got a RewriteRule for this, this is my whole htaccess code :

RewriteEngine On
RewriteRule ^kontakt contact.php [NC]
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

I'd like to don't change my html code in 30 files so here is my question :

Is any way to DON'T CHANGE html code and make this?

Clicking at <a href="contact.php"> makes url to www.example.com/kontakt

1 个答案:

答案 0 :(得分:0)

尝试此代码

RewriteEngine On

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteRule ^kontakt contact.php  [L,NC,R=301]