hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : how to do mod rewrite?
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

how to do mod rewrite?

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 08-06-2005, 06:43 PM
slee slee is offline
Junior Guru Wannabe
 
Join Date: May 2003
Posts: 82

how to do mod rewrite?


i have 4 pages on a site like this:

index.php?linkhdr=home
index.php?linkhdr=prices
index.php?linkhdr=links
index.php?linkhdr=contact

how do i use the apache mod rewrite to make it www.url.com/home/
www.url.com/prices/
www.url.com/links/
www.url.com/contact/

any help is much appreciated

__________________
Acne care
play guitar

Reply With Quote


Sponsored Links
  #2  
Old 08-07-2005, 12:04 AM
ChristsLittleFlock ChristsLittleFlock is online now
Web Hosting Master
 
Join Date: Jan 2005
Location: Johnstown, Pennsylvania
Posts: 1,205
Perhaps try this:

Code:
RewriteEngine On
RewriteRule ^([a-zA-Z0-9]+)$ /index.php?linkhdr=$1

__________________
CLF Cloud Shared Hosting
Hosting by Catholics. Build your own package with dedicated resources. CloudLinux/LiteSpeed/MariaDB. 24x7 support
Need web development, system administration, or server optimization? Request a quote.

Reply With Quote
  #3  
Old 08-07-2005, 12:45 AM
rmm5t rmm5t is offline
Newbie
 
Join Date: Aug 2005
Location: Virginia
Posts: 9
This is pretty close but might be more useful:
Code:
RewriteEngine On
RewriteBase /
RewriteRule ^([^/]+)/?$ /index.php?linkhdr=$1
This handles a few more cases than the previous post. Plus you can also check to make sure that the path isn't a directory or file first with this placed before the previous RewriteRule:
Code:
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [L]
If the path is a file or directory, no other rewrite rules are considered. This kind thing prevents something like /images/ getting replaced with /index.php?linkhdr=images. I doubt the latter is what you'd want.

__________________
FitFreak.net


Reply With Quote
Sponsored Links
  #4  
Old 08-07-2005, 06:57 PM
slee slee is offline
Junior Guru Wannabe
 
Join Date: May 2003
Posts: 82
i cant get this to work ive tried all of the above.

there is the above and one other file in the root called enquiry.php

what am i doing wrong?

__________________
Acne care
play guitar

Reply With Quote
  #5  
Old 08-07-2005, 07:45 PM
Elliot A Elliot A is offline
Web Hosting Guru
 
Join Date: Oct 2004
Location: Brisbane, Australia
Posts: 256
Are you sure your putting it in a .htaccess file and that it is accessable?

If you are, post any errors your getting.

__________________
Elliot Anderson
PHP, Python and Ruby Developer


Reply With Quote
  #6  
Old 08-08-2005, 05:29 AM
slee slee is offline
Junior Guru Wannabe
 
Join Date: May 2003
Posts: 82
ye im putting it in a .htaccess file and ive made it accessible.

i dint actually have any errors it just doesnt work.

if i go to www.url.com it says im forbidden to access the index.php file.

__________________
Acne care
play guitar

Reply With Quote
  #7  
Old 08-09-2005, 12:26 AM
outrigger outrigger is offline
Newbie
 
Join Date: Aug 2005
Location: Australia
Posts: 7
try this it may do the job for you.

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/index.php?linkhdr=([a-z0-9]*)
RewriteRule ^(.*) /%1/

Reply With Quote
  #8  
Old 08-09-2005, 02:41 AM
yabsoft yabsoft is offline
Newbie
 
Join Date: Jun 2005
Posts: 26
RewriteEngine on

#match top cat
RewriteRule ^([^\.]+)/$ index.php?linkhdr=$1&rule=1 [L]

Try the above code.

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Open Source Hosting - Challenges and Opportunities for Service Providers Web Hosting News 2012-12-10 10:33:18
ProfitBricks Says its New “Next Generation Cloud” Outperforms Amazon, Rackspace Web Hosting News 2012-09-10 16:35:00
Web Host WebHostForASP.net Launches VPS Hosting Service Web Hosting News 2012-06-29 14:52:22
Q&A: Toby Owen on Rackspace's Updated Hybrid Cloud Solution Web Hosting News 2011-11-08 21:31:27


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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 Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?