简体   繁体   中英

How to use mod_rewrite to write SEO friendly url

I have been at this for about 4 hours now and can't figure out what I'm doing wrong.

Here is my url: http://localhost/mywebsite/public/jobs.php?seo_url=retail-store-manager-mr-nice-guy

I want it to be this: http://localhost/mywebsite/public/jobs/retail-store-manager-mr-nice-guy

Here is my .htaccess mod_rewrite:

RewriteRule ^([a-zA-Z0-9_-]+)$ jobs.php?seo_url=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ jobs.php?seo_url=$1

Any help is much appreciated! I have already verified mod_rewrite is enabled/turned on with my Apache server.

This is how I got mine to work with my website

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteRule ^mywebsite/public/jobs/(.+)/?$ /mywebsite/public/jobs.php?seo_url=$1 [NC,L]
</IfModule>

Did this a while ago but learnt from here

http://httpd.apache.org/docs/current/mod/mod_rewrite.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM