Forum Moderators: phranque
My site creates a page at http://www.example.com/fnamelname/index.php
I create this page and in there i redirect to and article page in joomla
HERE:
This is how Joomla renders the article
http://www.example.com/index.php?option=com_content&view=article&id=10&name=fnamelname
In the article i have code that would then render the page via php get fnamelname.
How do i write this in .htaccess on my server?
Basically from this url:(http://www.example.com/fnamelname/index.php) to this url : (http://www.example.com/index.php?option=com_content&view=article&id=10&name=fnamelname)
Is it possible that after or before the article is rendered that the url shows like this
http://www.example.com/fnamelname/
[edited by: jdMorgan at 7:33 pm (utc) on Dec. 24, 2009]
[edit reason] example.com [/edit]
I really would like to create a static file in this directory /people/fnamelname/
And then have this redirect to http://www.example.com/fnamelname/
So as to not have to create all those directories in the www folder.
Then I am also trying to render this via an article with php and i need to pass that longer joomla url like so
http://www.example.com/index.php?option=com_content&view=article&id=10&name=fnamelname
[edited by: jdMorgan at 7:33 pm (utc) on Dec. 24, 2009]
[edit reason] example.com [/edit]
Notice that this is a URL-to-filepath translations, not a URL-to-URL redirect. In order to make any progress, that point and the great and important difference between a URL and the filepath that it resolves to must be thoroughly-understood.
You don't need (or want) to have a 'real file' at http://www.example.com/fnamelname/, just a rule to rewrite that URL, when requested by a client, to the proper script filepath with a proper query string.
The problem is that you've got several variables in the filepath query string, and mod_rewrite has no way to know what values to put in there, because they are not provided in the friendly URL. Therefore, this problem is un-solvable without using a database lookup to get the necessary variable value(s).
So, you'd need to modify Joomla or put a 'wrapper' script around it to take 'fnamelname' and look up "id=10" at least. It may be safe to assume that 'view=article' is already implied by the '/fnamelname' URL, but I can't be sure. However, it's obvious that you'll have to look up the id number somehow...
The alternative is to create and link to URLs like "examnple.com/fnamelname-10/" or "example.com/fnamelname/10" so that the id number is also provided in the 'friendly' URL, and can therefore be 'copied' by mod_rewrite into the "id=" variable value.
Jim
The reason why I would like to create a static file in a directory such as http://www.example.com/fnamelname/ is because I want search engines to be able to index that page there for better rankings. But my dilema would be that that page would exist outside joomla.
So the reason why I would want to redirect to that long joomla url so that i can pass the variable fnamelname and then render the article.
So basically what it turns out to be is to
Convert this : http://www.example.com/people/fnamelname/123456/index.html or index.php
to
http://www.example.com/fnamelname/
I still dont know how joomla will read this rather than
http://www.example.com/index.php?option=com_content&view=article&id=10&name=fnamelname
Since the article page requires all those variables to create the article
[edited by: jdMorgan at 7:35 pm (utc) on Dec. 24, 2009]
[edit reason] example.com [/edit]
#RewriteRule ^([A-Za-z-]+)/?$ index.php?option=com_content&view=article&id=10&name=$1 [L]
However it redirects my admin login to that page, which is what i dont want.
Also it doesnt work for http://www.example.com/fnamelname/index.html
[edited by: jdMorgan at 7:35 pm (utc) on Dec. 24, 2009]
[edit reason] example.com [/edit]
RewriteBase /
#
RewriteCond [b]$1 !^a[/b]dministrator
RewriteRule ^([a-[b]z\-][/b]+)/?$ index.php?option=com_content&view=article&id=10&name=$1 [[b]NC[/b],L]
For fastest results in this (or any other) forum, please give this information:
In general, the more details, the better.
Also, do be sure to completely flush (delete) your browser cache after uploading any new code to your server. Otherwise, you will likely see stale pages and server responses which were previously cached by your browser.
Jim
I needed to exclude all the other directories and that fixed the problem. Thanks alot for your help in solving this issue, I really appreciate it. However, Im not so sure if you can help me in this but I have a couple more questions that I hope you don't mind answering.
The site I am trying to create has to be SEO. Therefore I figure that I need to create an actual static page at for example : http://www.example.com/people/fnamelname/
The people subdirectory would be so that the root doesn't get cluttered and and so that search engines detect static content on that page.
I figured I could then rewrite this url to
http://www.example.com/fnamelname/
and then submit this to google via sitemaps feature.
The questions are:
1.Would this work?
2.Which url would be better for google to index?
3.Is it neccessary to create a static page in that directory? Would it get indexed?
URLs are used on the Web. They are not used inside a server. Filenames are used inside servers. They are not used at all on the Web. These are two very different things. You create a URL by publishing a link to it, nothing else is required; if you make a link to a URL, then that URL exists. You create a file on your server. It certainly exists, even if nothing else ever refers to it.
The primary job of a server is to associate an incoming request for a URL with a file on the server. This file may have a similar name to the URL, but they are *never* identical, because the protocol and domain are not needed once the request has arrived "inside" this server, and the hard drive, Apache install path, and 'account' directory are never published on the Web.
In other words, you can set up your server to associate any file with any URL, whether that means mapping URL example.com/foo/bar to file c:\\Program Files\Apache\site1\var\www\foo\bar.html or alternately, mapping
URL example.com/foo/bar to file c:\\Program Files\Apache\site1\var\www\index.php?dir=foo&name=bar
No agent (browser, robot, etc.) on the Web cares which of these designs you choose, as long as they get the content they want when they request the example.com/foo/bar URL.
Until this is perfectly clear, you'll likely make little progress. I would also suggest --as politely and gently as possible-- that you should not even think about coding until you are completely comfortable with these concepts, have researched the SEO aspects of your questions for several months, and have studied the mod_rewrite documentation, tutorials, and many examples of what other Webmasters are using. While it might be bad to have to wait awhile to implement your current concept, consider that it would be much worse to implement a concept with a single flaw in it.
Jim