Symlink Blog Post

Ask about a PHP problem here.
Post Reply
User avatar
FrederickGeek8
Posts: 148
Joined: Wed Nov 30, 2011 10:31 pm

Symlink Blog Post

Post by FrederickGeek8 »

I have absolutely no idea how to do this but how can I symlink blog posts like they do in wordpress so it would look like
read.php?aid=16
to
/look-at-me/
or
/look-at-me-2/
User avatar
Helx
Posts: 350
Joined: Thu May 17, 2012 6:45 am
Location: Auckland, New Zealand

Re: Symlink Blog Post

Post by Helx »

Its .htaccess (Mod_rewrite)
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /b/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>

# END WordPress
User avatar
FrederickGeek8
Posts: 148
Joined: Wed Nov 30, 2011 10:31 pm

Re: Symlink Blog Post

Post by FrederickGeek8 »

I am really confused on this. How would I link post id 16 to /hello-world/ and post id 17 to /hello-people/ and stuff.... I would really like to understand this really
User avatar
Helx
Posts: 350
Joined: Thu May 17, 2012 6:45 am
Location: Auckland, New Zealand

Re: Symlink Blog Post

Post by Helx »

Well, the /hello-world/ would be a $_GET variable, so you could just use that in your script to find it in a DB

I really don't know, I just found the .htaccess :3

EDIT: found an easier one to understand
RewriteEngine On
RewriteRule ^aid/([a-zA-Z0-9_-]+)$ index.php?aid=$1
if you had website.com/blog/?aid=43, you'd be able to navigate to website.com/blog/aid/43
Its the same concept as the ?aid= thing. You can still echo $_GET['aid'];
Post Reply