This is a discussion on URL routing and .rss files... thoughts? within the PHP General forums, part of the PHP Programming Forums category; I'm using URL routing to display a user's rss feeds. However, these feeds are physically stored in a ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I'm using URL routing to display a user's rss feeds. However, these
feeds are physically stored in a separate directory. So when someones goes to say: http://site.com/users/jon/feed.rss The URL rounting parses the /users/ /jon/ and feed.rss and currently redirects to the physical location of the .rss feed. Is there a way to mask the URL switch so when someone goes to that .rss link it appears as if the folder and file do in fact reside in the that directory? Or perhaps I should read the .rss and output it? Thoughts? |
|
|||
|
You could use mod_rewrite in the document root .htaccess:
RewriteEngine on RewriteRule /users/([^/]*)/([^\.*].rss) /otherdir/$1/$2 [L] If you need more advanced processing, use an internal PHP script, like so: http://www.seochat.com/c/a/Link-Trad...-your-Website/ On Jun 16, 1:21 pm, JonnyAJAX <jon.cianciu...@gmail.com> wrote: > I'm using URL routing to display a user's rss feeds. However, these > feeds are physically stored in a separate directory. > > So when someones goes to say:http://site.com/users/jon/feed.rss > > The URL rounting parses the /users/ /jon/ and feed.rss and currently > redirects to the physical location of the .rss feed. > > Is there a way to mask the URL switch so when someone goes to > that .rss link it appears as if the folder and file do in fact reside > in the that directory? > > Or perhaps I should read the .rss and output it? > > Thoughts? |
|
|||
|
Thanks for the reply!
I can't seem to get it to work though... perhaps if I describe my desired result you can help me construct the proper .htaccess syntax. What I need is for anytime a some goes to: http://mysite.com/users/username => it loads xxx.php but when someone goes to: http://mysite.com/users/username/somefeedtitle.rss => it goes to http://mysite.com/userfiles/username/somefeedtitle.rss Note that username can be letters, numbers and underscores. Here's my current .htaccess (which loads router.php all the time): RewriteEngine On RewriteRule /users/([^/]*)/([^\.*].rss) /userfiles/$1/$2 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} ^/users/(.*) RewriteRule . router.php |
|
|||
|
I think the rule may have a typo. Please try:
RewriteRule ^/users/([^/]*)/([^\./]*\.rss)$ /userfiles/$1/$2 [L] If it doesn't work, try without the rules for router? On Jun 17, 10:45 pm, JonnyAJAX <jon.cianciu...@gmail.com> wrote: > Thanks for the reply! > I can't seem to get it to work though... perhaps if I describe my > desired result you can help me construct the proper .htaccess syntax. > > What I need is for anytime a some goes to:http://mysite.com/users/username=> it loads xxx.php > > but when someone goes to:http://mysite.com/users/username/somefeedtitle.rss=> it goes tohttp://mysite.com/userfiles/username/somefeedtitle.rss > > Note that username can be letters, numbers and underscores. > > Here's my current .htaccess (which loads router.php all the time): > > RewriteEngine On > RewriteRule /users/([^/]*)/([^\.*].rss) /userfiles/$1/$2 [L] > > RewriteCond %{REQUEST_FILENAME} !-f > RewriteCond %{REQUEST_FILENAME} !-d > RewriteCond %{REQUEST_URI} ^/users/(.*) > RewriteRule . router.php |