Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-23-2011, 06:16 PM   PM User | #1
conware
Regular Coder

 
Join Date: Mar 2010
Posts: 195
Thanks: 77
Thanked 5 Times in 5 Posts
conware is an unknown quantity at this point
[SOLVED] - htaccess mod_rewrite file

Hi guys Im trying to rewrite my news.php to news/ as if its a directory.
But the problem is when I rewrite it like that and someone removes the /
The page will display a 404 message now this seems right sins I did rewrite it to news/ but how would I be able to still display it when someone removes that /

This is my htaccess code so far.
Thanks for the help.

Code:
<IfModule mod_rewrite.c>
	RewriteEngine on
	RewriteRule ^news/$ news.php [L]
</IfModule>

Last edited by conware; 03-23-2011 at 06:31 PM.. Reason: Thread has been solved!
conware is offline   Reply With Quote
Old 03-23-2011, 06:22 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Add a ? after the /. That makes it optional.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
conware (03-23-2011)
Old 03-23-2011, 06:29 PM   PM User | #3
conware
Regular Coder

 
Join Date: Mar 2010
Posts: 195
Thanks: 77
Thanked 5 Times in 5 Posts
conware is an unknown quantity at this point
Thanks for the tip Fou-Lu. works like a charm
conware is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:06 PM.


Advertisement
Log in to turn off these ads.