How to remove id from this url?

236 views Asked by At

I need to remove /photo/26/ from this url http://localhost/photo/26/h-house

I already have removed index.php from all links.

1

There are 1 answers

0
MrWhite On

You can do something like the following at the top of your .htaccess file using mod_rewrite to redirect /photo/26/h-house to /h-house, effectively removing /photo/26 from the URL:

RewriteRule ^photo/26/h-house$ /h-house [R=302,L]

Or, to avoid repetition, you can do the following instead:

RewriteRule ^photo/26(/h-house)$ $1 [R=302,L]

$1 is a backreference that contains /h-house from the capturing group in the RewriteRule pattern.