stop rewriting?

New to mod_rewrite? This is a good place to start.

stop rewriting?

Postby marcelloma » Mon Sep 21, 2009 11:43 am

I have a page named
Code: Select all
gallery-giacalone.php
which I want it to be accessed only via this two urls


Code: Select all
RewriteRule italiano/foto-appartamento-palermo-centro.html gallery-giacalone.php [env=lang:italiano,NE,L]
RewriteRule english/photos-apartment-palermo.html gallery-giacalone.php [env=lang:english,NE,L]


If someone directly asks for gallery-giacalone.php the access should be forbidden, so I wrote

Code: Select all
RewriteRule gallery-giacalone.php errors/page-not-found.php [L]


but if I ask one of the "valid" urls it still takes me to the not found page!
I know it's because "italiano/foto-appartamento-palermo-centro.html" gets rewritten and the rewrites starts all over with gallery-giacalone.php but isn't the L supposed to stop the rewrite process? What can I do?
marcelloma
 
Posts: 9
Joined: Sat Sep 12, 2009 4:14 am

Postby marcelloma » Mon Sep 21, 2009 11:55 pm

nobody?
Basically I want user to access a page through a forced rewrite and not directly..
marcelloma
 
Posts: 9
Joined: Sat Sep 12, 2009 4:14 am

Postby richardk » Tue Sep 22, 2009 9:29 am

nobody?

Patience?

Code: Select all
# Don't match internal requests.
RewriteCond %{ENV:REDIRECT_STATUS} ^$


Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^gallery-giacalone\.php$ /errors/page-not-found.php [L]

RewriteRule ^italiano/foto-appartamento-palermo-centro\.html$ /gallery-giacalone.php [E=lang:italiano,L]
RewriteRule ^english/photos-apartment-palermo\.html$          /gallery-giacalone.php [E=lang:english,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby marcelloma » Tue Sep 22, 2009 10:39 am

All right, thanks..why did you remove the NE flag?
I could have anchor links in the pages.. and not get escaped the # sign.
marcelloma
 
Posts: 9
Joined: Sat Sep 12, 2009 4:14 am

Postby richardk » Tue Sep 22, 2009 11:26 am

Anchor links are not sent in the HTTP request, they stay in the browser. The NE flags aren't needed.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 29 guests

cron