Hello everybody, I have a quick question about the mod_rewrite command in Apache. I may need some code samples, so be prepared
I appreciate any help I can get. Feel free to email me at [email protected] Thanks!
So, what is your question about mod_rewrite ? Mod_rewrite commands useful when you need to do some fancy redirect, prevent hotlining to images on your website, etc. Here is an example of url rewriting commands in .htaccess
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ /index.php?page=$1
The example above is a common trick to make URLs SEO-friendly. For example, if you have page on your website:
http://www.mysite.com/index.php?page=contact
the above rewrite rules will make this page also available by this address:
http://www.mysite.com/contact
Alright so I am using a CMS to display articles. When you click on the “Read More…” link I would love it to go to "mysite.com/articles.php?uid=some article uid. So in short this code will provide the link:
[php]
And I need it to properly insert the uid field included in the link into this:
[php]<?php echo $apicms->content(uid)->getHtml(); ?>[/php]
Then display the link like this:
And if I can type that rewritten link into my browser and get the redirect to work that would be fantastic as well
And somebody told me that I need to include this somewhere:
[php]$_REQUEST[‘id’][/php]