Reputation: 101
I have this link that works and leads to the correct article:
<a href="https://www.example.com/news/21/Hello-World">Article</a>
<a href="https://www.example.com/news/Hello-World">Article</a>
Options -MultiViews
ReWriteEngine On
RewriteBase /
RewriteRule ^news/(\d+)/([\w-]+)/?$ news.php?id=$1&linkAddress=$2 [NC,L,NE]
Is it poosible to remove the 21 id from the link but still use the id to get the variables from database. thanks.
Upvotes: 2
Views: 124
Reputation: 133428
Could you please try following, written based on samples. Please make sure you clear your browser cache after placing these urls in your .htaccess file. Also make sure this new rule is above your already existing news.php
rule(shown in your samples).
RewriteEngine ON
RewriteRule ^(news)/(Hello-World)/?$ $1/21/$2 [NC,L]
##Placing OP's rule to serve urls starting with news with news.php in backend.
RewriteRule ^news/(\d+)/([\w-]+)/?$ news.php?id=$1&linkAddress=$2 [NC,L,NE]
Upvotes: 3