What regular expression need to use for rewriting url having in input something as:
http://domain.ext/mydir/subdir/page.php
and in output something as:
http://domain.ext/mydir-subdir-page.php
The "mydir" is a constant. "subdir" and "page" are variables. I have tried with:
<IfModule mod_rewrite.c>
RewriteEngine on
Options +FollowSymlinks -MultiViews
RewriteRule ^([a-z0-9]+)/mydir/([a-z0-9]+)/([a-z0-9]+)/?$ /mydir/$1-$2.php [QSA,L]
</IfModule>
but don't work. Thanks.
You're forcing the rewrite to only occur if there alphanumeric characters before /mydir/
which will never happen.
Edit: Assuming from your comment that you wish to rewrite /mydir-subdir-page.php
to /mydir/subdir/page.php
, update your rewrite as follows
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^/mydir-([^/]+)-([^/]+).php$ /mydir/$1/$2.php [QSA,L]
</IfModule>