Home Multiple htaccess rewrite rule
Reply: 0

Multiple htaccess rewrite rule

user1044
1#
user1044 Published in May 20, 2018, 10:13 am

here is my code for .htaccess file

Options -Indexes
RewriteEngine On
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d
RewriteRule ^([a-z0-9]+)$ /profile.php?username=$1 [L]
RewriteRule ^([a-z0-9]+)$ /display.php?page=$1 [L]

For the first one it works correctly and is displaying like this: www.site.com/user

The second one is not working, normally is displaying like this www.site.com/display.php?page=10. I want to display the page like this www.site.com/article I tried different things and no result. Please tell me how to make to work with multiple rules. Also please give me an advice on how to use this functionalities in php because I think I done something not really good. My php code for using this rule is:

<p><a class="button" href="/<?php echo $user_data['username']; ?>"> Profile</a></p>

It works, but maybe is a better way to make a link to take advantage of htaccess.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.340674 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO