Htaccess Remove part of URL

后端 未结 2 404
忘掉有多难
忘掉有多难 2021-01-27 20:19

I have this URL: http://www.website.nl/pagina/4/wie-ben-ik.html

\"pagina\" is a real php document. \"4\" is the id of the webpage, with the id I get the results from the

2条回答
  •  情深已故
    2021-01-27 20:34

    Try adding the following to the .htaccess file in the root directory of your site.

    RewriteEngine on
    RewriteBase / 
    
    #redirect http://www.website.nl/pagina/4/wie-ben-ik.html to http://www.website.nl/wie-ben-ik 
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /pagina/4/(wie-ben-ik)\.html [NC]       
    RewriteRule ^ %1 [L,R=301]
    
    #process wie-ben-ik as http://www.website.nl/pagina/4/wie-ben-ik.html
    RewriteRule ^([-a-zA-Z]+)$  pagina/4/$1.html [L,NC] 
    

提交回复
热议问题