简体   繁体   中英

mod_rewrite not making my url pretty

I know this might be a simple fix but I cannot figure it out.

I have my .htaccess file in folder called videos that is in my root file.

I wrote this rewrite mod:

<IfModule mod_rewrite.c>
RewriteEngine On


RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.php -f
RewriteRule ^(.*)$ $1.php [L]

RewriteRule ^videos/([a-z0-9\-]+)$ vid.php?=$1 [L]
</IfModule>

For some reason my url still comes up like this:

http://localhost/fap2/videos/vid.php?id=1

It does not replace that ?id=1 with just the number 1 like vid.php/1


Also since that vid.php?id=1 is from a href on index.php, and It looks like this:

<a href="videos/vid.php?id=' . $tag["video_tag"] .'">

my pages are based on that id. Can I somehow show the id category name instead of a numer so for example that vid.php?id=1 be that actual name vid.php/category1 or is that based on changing that a href tag?

Thank you

try this

RewriteEngine on
RewriteBase /fap2/
RewriteRule ^videos/([^/]+) vid.php?id=$1 [L]

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