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 ...


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 10-07-2009, 10:59 PM
jaysunn's Avatar
Powered By Linux
User
 
Join Date: Apr 2009
Location: 41.332032,-73.089775
OS: RHEL - OSX
Posts: 600
Thanks: 61
Thanked 78 Times in 70 Posts
Rep Power: 10
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 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
__________________
Have a look at what I have been working on
http://www.shellasaurus.com
Reply With Quote
  #2 (permalink)  
Old 10-07-2009, 11:17 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,710
Thanks: 11
Thanked 244 Times in 183 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 10-07-2009, 11:26 PM
jaysunn's Avatar
Powered By Linux
User
 
Join Date: Apr 2009
Location: 41.332032,-73.089775
OS: RHEL - OSX
Posts: 600
Thanks: 61
Thanked 78 Times in 70 Posts
Rep Power: 10
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 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
__________________
Have a look at what I have been working on
http://www.shellasaurus.com
Reply With Quote
  #4 (permalink)  
Old 11-07-2009, 01:01 AM
jaysunn's Avatar
Powered By Linux
User
 
Join Date: Apr 2009
Location: 41.332032,-73.089775
OS: RHEL - OSX
Posts: 600
Thanks: 61
Thanked 78 Times in 70 Posts
Rep Power: 10
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 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
__________________
Have a look at what I have been working on
http://www.shellasaurus.com
Reply With Quote
  #5 (permalink)  
Old 11-07-2009, 05:57 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,710
Thanks: 11
Thanked 244 Times in 183 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 27-01-2009 01:28 AM
clean table with cron job verbatim Shell scripting 1 09-07-2008 07:11 PM
Lighttpd Gallery2 URL Rewrite (.htaccess) SEO Rules rootadmin Web servers 2 22-06-2008 06:57 PM
/tmp clean directory automatically using tmpwatch tanachi Getting started tutorials 4 24-05-2007 10:58 AM
.htaccess problems rcordeiro Linux software 4 05-07-2006 07:32 PM


All times are GMT +5.5. The time now is 03:40 PM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 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