473,765 Members | 1,994 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mod_rewrite - Help, I'm a newbie...

13 New Member
I've got URLs that look like:
Expand|Select|Wrap|Line Numbers
  1. www.mysite.com/template.php?id=pagetitle
  2. www.mysite.com/template.php?id=folder/pagetitle

I want the URLs to look like:
Expand|Select|Wrap|Line Numbers
  1. www.mysite.com/pagetitle
  2. www.mysite.com/folder/pagetitle

How do I write this RewriteRule into my .htaccess file? Or, is there a better way.

I originally wrote a separate rule for every single URL, but, as you could imagine, the performance of the site took a huge hit. (see example below).

Expand|Select|Wrap|Line Numbers
  1. RewriteEngine On
  2. RewriteRule ^$ http://www.mysite.com/template.php?id=home
  3. RewriteRule ^(about/history/|about/history)$ template.php?id=about/history
  4. RewriteRule ^(services/|services)$ template.php?id=services
  5. RewriteRule ^(contact/|contact)$ template.php?p=contact
  6.  
  7. etc., etc., etc.
  8.  
And I thought, "There must be a way to write one or two rules that would cover all these URLs." Any help would be great.

Also, I'm a newbie to code -- design's my gig -- so directing me to the Apache docs will not help me much, unfortunately (as it's Greek to me).

Perhaps an example, or citing an article with examples would help me.

Thank you very much.
Brad
Nov 18 '06 #1
0 2023

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2279
by: Westcoast Sheri | last post by:
Hello. How do I do this: If a visitor types in any number after my url, I want mod_rewrite to convert it to my url/anotherpage.html?number=number_visitor_typed Example: http://www.mysite.com/12345678.html would result in:
4
2551
by: Support | last post by:
Hello, I am running RedHat & Apache. RedHat does not allow creating more that 32000 subdirectories in one folder due to #defined constant limitation in the core code. I need to display 47000 directories on web page: e.g. mydomain.com/andrew , mydomain.com/bill , etc. Each directory contains .html/htm files and image files (*.jpg, *gif, jpeg etc.)
2
2758
by: Jon Maz | last post by:
Hi All, Forgive a newbie-ish question here, but I've not been long in the Apache / PHP world. I'm just learning about mod_rewrite, and a question occurred to me. Once Apache has rewritten a url, the php page can (obviously) see the *rewritten* url and access it via $_GET. But does php have any access to the *original* url? I'm told that Apache *does* expose both urls (original and rewritten), it's just a question of whether the php...
6
1758
by: namemattersnot | last post by:
ok. i give up. need help :) here's the rule: RewriteRule ^test/(.+)/(.*)$ /index.php$2 if i request: http://localhost/test/keyword/?show=files it properly redirects me. NOW, if i change the rule to: RewriteRule ^test/(.+)/(.*)$
11
2080
by: joelbyrd | last post by:
I have a people-networking type site in which each user has their own profile page, with their user id encoded. So, for example, the web address of their page might look like "www.example.com/my_profile.php?user_id=fdjkhfh2489298hf298h3s0dhfxj". I want the users to be able to choose their own web address that would look like "www.example.com/Joel", and then when they type in that address, they are automatically redirected to their profile...
4
2485
by: Hermann.Richter | last post by:
I want to rewrite URLs like http://domain/dir/file.php?var1=val1&var2=val2#anchor to http://domain/dir/file?var1=val1&var2=val2#anchor In other words, I want to strip out the php extension I tried putting in the .htaccess file the following:
5
4844
by: laredotornado | last post by:
Hi, I have verified that mod_rewrite is enabled on my Apache 2.2 instance. However, now I'm having a problem just serving pages using .htaccess files. Following Rik's advice, my .htaccess file is as follows RewriteEngine On RewriteCond %{REQUEST_FILENAME} -f RewriteCond %{REQUEST_FILENAME} !^accesscontrol.php
3
1856
by: dennis.sprengers | last post by:
* I'm trying to work out some rewrite rules that should do the following: case 1: a request to mysite.com: rewrite http://www.mysite.com/files/sheets.ppt to http://www.mysite.com/sites/default/files/sheets.ppt case 1 - n: a request to othersite.com: rewrite http://www.othersite.com/files/sheets.ppt to http://www.othersite.com/sites/othersite/files/sheets.ppt
7
1740
by: Dale | last post by:
again, i know this is OT...just move along to the next post if it bugs you. :) i had been trying to have this: project.66.204.32.110 from the client browser, map to a virtual host where the document root would be:
0
9566
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9393
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9946
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9832
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7371
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5272
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5413
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3921
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.