LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-08-2011, 03:51 AM   #1
sunlinux
Member
 
Registered: Feb 2006
Distribution: RHCL 5
Posts: 229

Rep: Reputation: 30
apache rewrite rule


how to apply below apache rewrite rule

url/new/onlocation/* url/A/B/en/new/onlocation.html
 
Old 11-08-2011, 04:33 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,516

Rep: Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501
Hi,

So you want anything under /new/onlocation/ to be rewritten, so it gives out the /A/B/en/new/onlocation.html page? If that's the case, you can use:
Code:
RewriteEngine On
RewriteRule new/onlocation/(.*) /A/B/en/new/onlocation.html
Regards
 
Old 11-08-2011, 04:49 AM   #3
sunlinux
Member
 
Registered: Feb 2006
Distribution: RHCL 5
Posts: 229

Original Poster
Rep: Reputation: 30
hi

that what i tried :

RewriteRule new/onlocation/(.*) /A/B/en/new/onlocation.html but didn't work

if I type in browser http://url/new/onlocation/new/onlocation/ it says 404 page not found:

if I type http://url/new/onlocation/new/onlocation/anything.html it takes me to onlocation.html (bit good)

but I want to type http://url/new/onlocation/new/onlocation/ this only. and it should take me to onlocation.html page
 
Old 11-08-2011, 05:17 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,516

Rep: Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501
Are you sure you have the trailing slash, before the (.*) in the rewrite rule?
Code:
RewriteRule new/onlocation/(.*) /A/B/en/new/onlocation.html
 
Old 11-08-2011, 05:59 AM   #5
sunlinux
Member
 
Registered: Feb 2006
Distribution: RHCL 5
Posts: 229

Original Poster
Rep: Reputation: 30
I have that but some how not working
 
Old 11-08-2011, 06:15 AM   #6
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by bathory View Post
Code:
RewriteRule new/onlocation/(.*) /A/B/en/new/onlocation.html
Is the ( ... ) significant when $1 is not used in the substitution?
 
Old 11-08-2011, 07:25 AM   #7
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,516

Rep: Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501
Quote:
Originally Posted by catkin View Post
Is the ( ... ) significant when $1 is not used in the substitution?
It is as the OP wants to rewrite everything after the slash to a predefined page


@OP
Quote:
I have that but some how not working
What is the page it tries to get, when you see the 404 error?
Maybe you can try this:
Code:
RewriteRule ^new/onlocation([^/]*) /A/B/en/new/onlocation.html
 
Old 11-08-2011, 10:53 AM   #8
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by bathory View Post
It is as the OP wants to rewrite everything after the slash to a predefined page
I can't reconcile that to the Rewrite rule documentation but I am fairly new to Apache configuration so that may not count for much.

EDIT: sorry; got it -- "Additional path information beyond the matched URL-Path will be appended to the target URL".

Last edited by catkin; 11-09-2011 at 02:35 AM.
 
Old 11-10-2011, 12:03 AM   #9
sunlinux
Member
 
Registered: Feb 2006
Distribution: RHCL 5
Posts: 229

Original Poster
Rep: Reputation: 30
no luck
 
Old 11-10-2011, 01:40 AM   #10
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,516

Rep: Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501
Quote:
Originally Posted by sunlinux View Post
no luck
Could you be more specific? Post the errors from error_log to see why you get the 404 error
 
Old 11-11-2011, 06:01 AM   #11
linuxwin2
Member
 
Registered: Oct 2011
Posts: 44

Rep: Reputation: Disabled
RewriteRule ^url/new/([a-z]+)$ url/A/B/en/new/$1.html
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
apache rewrite rule sunlinux Linux - Server 2 09-25-2011 03:03 PM
Need help with apache Rewrite Rule? your_shadow03 Linux - Newbie 1 01-21-2010 08:12 AM
Linux Apache Rewrite Rule jon_k Linux - Software 1 06-10-2009 03:09 AM
Apache rewrite rule help kinetik Linux - Software 1 11-05-2007 12:18 PM
Help me make this rewrite rule in Apache ganninu Linux - General 8 01-07-2004 09:30 AM


All times are GMT -5. The time now is 02:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration