homepage Welcome to WebmasterWorld Guest from 174.129.80.166
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Website
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Help With Couple Rules For my site
Need to know how to go about doing this
ivanvias




msg:4047940
 10:58 pm on Dec 22, 2009 (gmt 0)

Hi all,

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]

 

g1smd




msg:4047948
 11:16 pm on Dec 22, 2009 (gmt 0)

If you want a URL to show in a certain way, then that is the URL that you need to link to from the pages of your site.

You'll then need an internal rewrite to accept that external URL request and then go fetch the content from some place inside the server.

ivanvias




msg:4047957
 11:29 pm on Dec 22, 2009 (gmt 0)

Can anyone show a quick example im newb to this. Sorry

ivanvias




msg:4047970
 11:41 pm on Dec 22, 2009 (gmt 0)

Would creating an actual directory as i have above be complex.

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]

g1smd




msg:4047993
 12:24 am on Dec 23, 2009 (gmt 0)

If a redirect takes place then the browser is told to go fetch a different URL in a new HTTP transaction.

A redirect cannot do what you want to do.

It would also be fatal for your site to send a redirect header when navigating the site via its own navigation.

jdMorgan




msg:4048049
 2:43 am on Dec 23, 2009 (gmt 0)

It's likely that you're looking to map 'friendly' URLs such as http://www.example.com/fnamelname/ to internal server filepaths such as /index.php?option=com_content&view=article&id=10&name=fnamelname

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

ivanvias




msg:4048092
 5:17 am on Dec 23, 2009 (gmt 0)

Yes there is much I need to learn about URL ReWrite I don't know where to Start.

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]

ivanvias




msg:4048571
 8:35 pm on Dec 23, 2009 (gmt 0)

Can anyone help out with this?

ivanvias




msg:4048596
 9:03 pm on Dec 23, 2009 (gmt 0)

Actually I have decided that fnamelname will be unique so i just need to pass fnamelname to the url.

ivanvias




msg:4048763
 2:54 am on Dec 24, 2009 (gmt 0)

I tried this and it seems to work:

#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]

g1smd




msg:4048826
 7:50 am on Dec 24, 2009 (gmt 0)

Use a preceding RewriteCond to exclude those URLs from triggering the Rule.

ivanvias




msg:4050594
 12:49 am on Dec 29, 2009 (gmt 0)

I have tested this Rewrite Cond and it seems to break all other urls.

#RewriteBase /

#RewriteCond %{REQUEST_URI} !^/(administrator¦administrator/.*)$

#RewriteRule ^([A-Za-z-]+)/?$ index.php?option=com_content&view=article&id=10&name=$1 [L]

jdMorgan




msg:4050643
 4:33 am on Dec 29, 2009 (gmt 0)

You can simplify that -- and speed it up:

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]

But what do you mean that your current rule 'breaks' all other URLs? By adding the RewriteCond, your rule now affects *fewer* URLs than it did before adding the RewriteCond, so new/additional problems are not to be expected by adding the RewriteCond.

For fastest results in this (or any other) forum, please give this information:

  • What URLs did you test with? For each URL:
  • What results did you expect?
  • What results did you actually get?
  • How do these differ?
  • Any error messages in the browser?
  • Any error information logged in the server error log?

    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

  • ivanvias




    msg:4050660
     6:02 am on Dec 29, 2009 (gmt 0)

    Okay,

    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?

    jdMorgan




    msg:4050839
     3:49 pm on Dec 29, 2009 (gmt 0)

    I don't really understand that question, but here's something to help: You need to stop thinking about URLs and files being the same thing, because that is probably why you're having trouble figuring this out.

    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

    Global Options:
     top home search open messages active posts  
     

    Home / Forums Index / Code, Content, and Presentation / Apache Web Server
    rss feed

    All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
    Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
    © Webmaster World 1996-2014 all rights reserved