简体   繁体   中英

Creating SEO URLs with slug and .htaccess

I am trying to create SEO URLs with PHP MySQL and .htaccess.

Here is my PHP code:

echo '<li>'.$icon.' <a href=\'software.php?pid='.softid.''.$slug.'\'>'.$title.'</a></li>';

The URL will be base_url/software-name-etc .

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /filemono-v2
RewriteRule ^software-profile/([a-zA-Z0-9_]-)/([0-9]+)\.php$ software-profile.php?pid=$1
</IfModule>

What's wrong with my code? I'm getting a 404.

YOu need to change your php code to reflect what your rewrite rule is matching against:

echo '<li>'.$icon.' <a href=\'/software-profile/'.$softid.'/'.$slug.'.php\'>'.$title.'</a></li>';

So the anchor should look like /software-profile/pid/slug.php

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