How to change URL? htaccess

前端 未结 2 1832
感情败类
感情败类 2021-01-25 05:01

What I have

newsy/czytaj/items/odbierz-250zl-na-reklame.html

This is what I would have

newsy/odbierz-250zl-na-reklame.html

相关标签:
2条回答
  • 2021-01-25 05:17
    RewriteEngine on
    RewriteRule ^newsy/([^\./]+)\.html /newsy/czytaj/items/$1.html [L]
    

    This will rewrite anything that starts with newsy and add a /czytaj/items between it and the html file.

    0 讨论(0)
  • 2021-01-25 05:37

    In principle you just create a corresponding rewrite rule:

    RewriteRule ^newsy/czytaj/items/(.+) /newsy/$1 [L]
    

    It is crucial not to omit [L]flag. Otherwise your rewrite engine may get stuck in an endless loop. Also in the beginning of the .htaccessfile remember to enable mod_rewrite with:

    RewriteEngine On
    

    For more help on mod_rewrite, I recommend checking out mod_rewrite-cheatsheet. For an exhaustive URl Rewriting Guide see a corresponding page from Apache 2.0 Documentation.

    0 讨论(0)
提交回复
热议问题