nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

.htaccess url rewrite clean URLS

This is a discussion on .htaccess url rewrite clean URLS within the Web servers forums, part of the Mastering Servers category; Hello All, I have been asked to create a .htaccess redirect. I have never attempted to work with one of ...

Register free or login to your existing account and remove all advertisements.


Go Back   nixCraft Linux Forum > Mastering Servers > Web servers

Linux answers from nixCraft.


Web servers Discussion on Apache, Nginx and Lighttpd HTTP/web server and configuration issues.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-10-2009, 11:59 PM
jaysunn's Avatar
Powered By Linux
User
 
Join Date: Apr 2009
Location: 41.332032,-73.089775
OS: RHEL - OSX
Posts: 525
Thanks: 54
Thanked 66 Times in 59 Posts
Rep Power: 8
jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold
Default .htaccess url rewrite clean URLS

Hello All,

I have been asked to create a .htaccess redirect. I have never attempted to work with one of these files. We have a pretty vanilla LAMP setup using rhel4 apache1.3 and php4.2.3.


I was instructed to place the .htaccess file in the document root of the site and and to attempt to get to work.

My goal is to have:
Code:
http://itm2108.com/yadayada/4778198
Redirect to:

Code:
http://itm2108.com/topic/traffic.php?

Here is what I have so far. And I just keep getting a 404. It has to be .htaccess file to. I can make the redirect in the vhost but that is not acceptable.

Code:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^/?traffic$ /topic/traffic.php
Thanks in advance.

Jaysunn
__________________
Give a man a fish, feed him for today.
Teach a man to fish, he will feed himself from now on.
Reply With Quote
  #2 (permalink)  
Old 07-11-2009, 12:17 AM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Posts: 2,452
Thanks: 11
Thanked 189 Times in 139 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Redirection and url rewritings are two different things. For e.g. when you visit www.nixcraft.com you will be redirected to nixcraft.com. This is redirection.

Rewriting url will not change url in browser, instead it will internally fetch result from original url. This is done for clean url or for SEO purpose. For e.g. when you visit http://nixcraft.com/web-servers/1326...-redirect.html this url rewritten as /showthread.php?t=13260 using the the pattern.

I guess you need 2nd option. Do you know your pattern?
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
  #3 (permalink)  
Old 07-11-2009, 12:26 AM
jaysunn's Avatar
Powered By Linux
User
 
Join Date: Apr 2009
Location: 41.332032,-73.089775
OS: RHEL - OSX
Posts: 525
Thanks: 54
Thanked 66 Times in 59 Posts
Rep Power: 8
jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold
Default

I actually explained that wrong. I need a url rewriting as you explained. Using the .htaccess file. I need for the browser to take the user to:

Code:
http://itm2108.com/topic/traffic.php?
When the user puts the below in the browser. Without a redirection and url change. So it should go to the above url and page. But the user should see below url in browser.

Code:
http://itm2108.com/traffic

Hope this makes sense. Thanks for the quick reply.

Jaysunn
__________________
Give a man a fish, feed him for today.
Teach a man to fish, he will feed himself from now on.
Reply With Quote
  #4 (permalink)  
Old 07-11-2009, 02:01 AM
jaysunn's Avatar
Powered By Linux
User
 
Join Date: Apr 2009
Location: 41.332032,-73.089775
OS: RHEL - OSX
Posts: 525
Thanks: 54
Thanked 66 Times in 59 Posts
Rep Power: 8
jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold
Default [solved]

[SOLVED]

Thanks for your help NIXCRAFT. I was working with my senior engineer and I was a bit confused. We added the following to the .htaccess file and it is now working the way we wanted.

Code:
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)/([0-9]+)$ /pages/$2\.php
RewriteRule ^/?traffic$ /topic/traffic.php
Thanks Again.

Jaysunn
__________________
Give a man a fish, feed him for today.
Teach a man to fish, he will feed himself from now on.
Reply With Quote
  #5 (permalink)  
Old 07-11-2009, 06:57 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Posts: 2,452
Thanks: 11
Thanked 189 Times in 139 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Glad to know it was sorted out ...
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
Reply

Tags
.htaccess , apache , httpd , linux , mod_rewrite , rhel


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Perl / Shell Regex to clean and remove all HTML tags cosminnci Coding in General 1 01-27-2009 02:28 AM
clean table with cron job verbatim Shell scripting 1 07-09-2008 08:11 PM
Lighttpd Gallery2 URL Rewrite (.htaccess) SEO Rules rootadmin Web servers 2 06-22-2008 07:57 PM
/tmp clean directory automatically using tmpwatch tanachi Getting started tutorials 4 05-24-2007 11:58 AM
.htaccess problems rcordeiro Linux software 4 07-05-2006 08:32 PM


All times are GMT +5.5. The time now is 06:30 PM.


Powered by vBulletin® Version 3.8.4 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2009 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38