Search code examples
.htaccessmod-rewrite

.httaccess issue - rewrite url


I have this URL: https://www.example.com/zitra/munch-edward-vykrik-(1910)-ido-6017 and I need to rewrite it into this shape: https://www.example.com/zitra/strany/jedenobraz.php?id=6017 (my issue is to add directory "strany" into final url). I'm using this rewrite rule:

RewriteRule (.*)-ido-(.*) jedenobraz.php?id=$2

I guess that's something with rewrite base, because on common.httacces testers a little bit different solution works and there is another working .htaccess file in root directory level. But I'm not able to handle it...

On example.com level is a working .httaccess, in directory zitra is .htaccess with "RewriteEngine off" and I'm testing everything in directory strany...

Many thanks for hints or tips in advance!


Solution

  • You can use this code inside zitra/.htaccess:

    RewriteEngine On
    RewriteBase /zitra/
    
    RewriteRule -(\d+)/?$ strany/jedenobraz.php?id=$1 [L,QSA]