Visit Our UNIX and Linux User Community


Tricky mod_rewrite for clean urls problems when fetching external sources


 
Thread Tools Search this Thread
Top Forums Web Development Tricky mod_rewrite for clean urls problems when fetching external sources
# 1  
Old 04-14-2010
Tricky mod_rewrite for clean urls problems when fetching external sources

Hi, I have problems with mod rewrite. I will try to describe...

I want clean urls but fail to make it work propperly. Maybe I have problems, because the content displayed is fetched from my other site...

There is a lot of stuff I already red about this, but somehow I can not find a solution for this:

Site 1 is used to fetch images for displaying on several other sites.

For example if I want to show a specific category the url is:
PHP Code:
http://www example1.com/show.php/tag=flower+red 
To view these flowers on an other site, I use some php code like this, what works wonderful for this "dirty urls":

PHP Code:
$url="$url1".substr(getenv('REQUEST_URI'),1);
$postdata "$url1";
$ch curl_init();
curl_setopt ($chCURLOPT_URL$url); 
So on the 2. Site this shows me the same flowers as requested on the url above.

PHP Code:
http://www example2.com/show.php/tag=flower+red 
But I need this request from the 2.Example-Site with clean urls. Like this:

PHP Code:
http://www example2.com/flower+red/ 
In .htaccess if the 2.Site I added this to make it work, but it fails:

PHP Code:
RewriteEngine On
RewriteRule 
^([^/]*)/$ /show.php?tags=$[L
From all I undertand from all this mod_rewrite, the following request should be the same:


PHP Code:
http://www example2.com/flower+red/ 
=
PHP Code:
http://www example2.com/show.php/tag=flower+red 
But the request, which goes to site1 in this example is:

PHP Code:
http://www example1.com/flower+red/ 
Why doesn't site2 rewrite this request propperly first to the "dirty url"?
# 2  
Old 04-16-2010
I am on my mobile phone so I can't see clearly. My first impression is that you need to return a 301 to get the redirect you are looking for,

---------- Post updated at 16:10 ---------- Previous update was at 13:43 ----------

OK, I checked this and your regex is not matching properly, but I can't tell from your post exactly what you want to match (and not want to match).

Please provide clear examples of the exact URIs you want to match and exactly what you want to replace with. Thanks.

---------- Post updated at 16:14 ---------- Previous update was at 16:10 ----------

On second thought, I can't answer because I can't understand your original question very well, sorry!
# 3  
Old 04-17-2010
I think the problem is that

PHP Code:
substr(getenv('REQUEST_URI'


is not rewritten back to

PHP Code:
show.php/tag=flower+red 

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

Sendmail external email delays and mailertables problems on Solaris

Setup is a Solaris 11 zone running sendmail as a relay to our actual mailservers. All emails to external domains seem to be being tried to be sent directly from this Solaris 11 zone which cannot send mail externally. All emails sent to our pager addresses as defined in the /etc/mail/aliases... (0 Replies)
Discussion started by: LittleLebowski
0 Replies

2. Shell Programming and Scripting

Problems with fetching data from Oracle database

Here's a database query which looks up the NAME column of PRODUCT table SELECT NAME FROM PRODUCT ; And this query retrieves me the following output SUGAR COCOA HONEY WHEAT CABBAGE CAULI FLOWER Please note the last record CAULI FLOWER contains TWO blank spaces between the two words. ... (4 Replies)
Discussion started by: kumarjt
4 Replies

3. Shell Programming and Scripting

Problems activating "mod_rewrite" (I can't edit 000-default file)

Hello everyone, Maybe an expert could help me.. I'm trying to activate mod_rewrite module on a Ubuntu 11.04 server (natty) and I having problem to edit the file 000-default in 3rd step, the steps to activate the module are: 1-Install Apache web server in Ubuntu Linux 2-Enable mod_rewrite... (6 Replies)
Discussion started by: cgkmal
6 Replies

4. Shell Programming and Scripting

Remove external urls from .html file

Hi everyone. I have an html file with lines like so: link href="localFolder/..."> link href="htp://..."> img src="localFolder/..."> img src="htp://..."> I want to remove the links with http in the href and imgs with http in its src. I'm having trouble removing them because there... (4 Replies)
Discussion started by: CowCow339
4 Replies

5. Web Development

mod_rewrite help

Here's my situation. When a user access the site domain.com it redirects to /portal which displays SKIN1 by default. When a user accesses the site domain.com/portal?branding=SKIN1 it displays SKIN1 by default as well. When a user access the site domain.com/portal?branding=SKIN2 it... (0 Replies)
Discussion started by: Adrnalnrsh
0 Replies

6. Shell Programming and Scripting

Rsync to an external list of URLs

I'm going to have a text file formatted something like this: some_name http://www.someurl.com/ another_name http://www.anotherurl.com/ third_name http://www.thirdurl.com/ I need to write a script that can rsync from a file path I'll set, to each URL in the list. Any ideas? (8 Replies)
Discussion started by: ibsen
8 Replies

7. Shell Programming and Scripting

mod_rewrite problem

hi i'm very new to mod_rewrite. I can't seem to have this work. I have a site which has 4 pages : home, links, adverts and contacts page. the adverts page is linked to this url http://www.xxxxxx.com/adverts.php. What i want is that whenever the adverts page is clicked , it will show... (0 Replies)
Discussion started by: arsonist
0 Replies

8. Solaris

Problems fetching EMC disks to Solaris OS.

Hi, I have a nasty little problem with my disks on my system My system configuration is as follows Sunv890 with sunos 9 connected tot a IBM6800 SAN using a 2port 2 GB qla2342 adapter. We have bought a EMC SAN. The company who sold us the san, said that it would be no problem connecting the... (10 Replies)
Discussion started by: orac
10 Replies

9. Filesystems, Disks and Memory

external USB detection problems

I have seagate USB 2.0 HDD which was working good on my windows system Recently I have started using red hat Linux 2.6.9-55.0.12.EL (i686 i686 i386 GNU/Linux) The USB is not at all detected in Linux even if I reboot with it attached to the PC. The same can be detected on any Windows system.... (2 Replies)
Discussion started by: mahendrakamath
2 Replies

10. Programming

Problems calling external C routines from PL/SQL

Hi everybody! I'm not familiar with C programming in Unix, but I'm trying to make work an example to execute external procedures (developed in C) from PL/SQL. The example includes .c and .pc source files, which I have compiled succesfully. After that, links the .o files into .so to declare... (0 Replies)
Discussion started by: lwnorowski
0 Replies

Featured Tech Videos