Hello,
I need some help with my mod_rewrite.
I have some rewrite rules in it already, which works fine, looks like this: Options +FollowSymlinks RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([\w\d~%.:_-]+)$ index.php?page=$1 [QSA]
So when I go to www.mydomain.com/news then it goes to www.mydomain.com/index.php?page=news
what I need more is that, when they go to www.mydomain.com/news/3 then it will go to www.mydomain.com/index.php?page=news&id=3 I’ve tried with this line: RewriteRule ^news/([0-9]+) /news.php?id=$1
Any question is, would it be able to replace id number with the name of the post, like instead of www.mydomain.com/news/3 it will be www.mydomain.com/news/this_is_the_news_title
Thanks
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Are you using WordPress? If not, you may want to consider it (given that it has a nice permalink module that automatically writes the <code>Mod_rewrite</code> rules for you.
Have you set AllowOverride All on apache? /etc/apache2/sites-available/yourdomain.com
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.