LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   apache rewrite rule (https://www.linuxquestions.org/questions/linux-newbie-8/apache-rewrite-rule-912430/)

sunlinux 11-08-2011 02:51 AM

apache rewrite rule
 
how to apply below apache rewrite rule

url/new/onlocation/* url/A/B/en/new/onlocation.html

bathory 11-08-2011 03:33 AM

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

sunlinux 11-08-2011 03:49 AM

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

bathory 11-08-2011 04:17 AM

Are you sure you have the trailing slash, before the (.*) in the rewrite rule?
Code:

RewriteRule new/onlocation/(.*) /A/B/en/new/onlocation.html

sunlinux 11-08-2011 04:59 AM

I have that but some how not working

catkin 11-08-2011 05:15 AM

Quote:

Originally Posted by bathory (Post 4518670)
Code:

RewriteRule new/onlocation/(.*) /A/B/en/new/onlocation.html

Is the ( ... ) significant when $1 is not used in the substitution?

bathory 11-08-2011 06:25 AM

Quote:

Originally Posted by catkin (Post 4518714)
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

catkin 11-08-2011 09:53 AM

Quote:

Originally Posted by bathory (Post 4518747)
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".

sunlinux 11-09-2011 11:03 PM

no luck

bathory 11-10-2011 12:40 AM

Quote:

Originally Posted by sunlinux (Post 4520263)
no luck

Could you be more specific? Post the errors from error_log to see why you get the 404 error

linuxwin2 11-11-2011 05:01 AM

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


All times are GMT -5. The time now is 01:20 AM.