gojobs gojobs - 3 months ago 5
PHP Question

Change URLs in PHP through .htaccess

I am asking question after so many attempts to do this. Found many results on this website but none of them worked for me.

I have a website built in PHP (no any CMS) that has URLS like

www.someweb.com/job_detail.php?job_id=123456789


I just want to convert all URLS like these

www.someweb.com/123456789


Here is my .htaccess content:

DirectoryIndex index.php
RedirectMatch 404 ^/admin/$
RedirectMatch 404 ^/admin/uploads/$
ErrorDocument 404 /page_not_found.php
<Files index.php>
Order deny,allow
deny from all
allow from all
</Files>


Please tell me how to do this? I think I need to do some change in just .htaccess

Answer

Try this:

RewriteEngine on
RewriteRule ^([0-9]+)/?$ /job_detail.php?job_id=$1 [L] 
Comments