Forum Moderators: phranque

Message Too Old, No Replies

Help with a rewrite

         

flexxall

5:13 pm on Sep 21, 2009 (gmt 0)

10+ Year Member



I am trying to rewrite the following and having issues acomplishing it

[mysite.com...] (index page)

written as

[mysite.com...]

Here is what I currently have in my .htaccess

<Files "config.php">
Order Allow,Deny
Deny from All
</Files>

<Files "common.php">
Order Allow,Deny
Deny from All
</Files>

<files .htaccess>
order allow,deny
deny from all
</files>

DirectoryIndex portal.php index.php index.html index.htm

RewriteEngine on
RewriteBase /
RewriteRule ^index\.(htm¦html¦php) http://mysite.com [R=301,L]

RewriteRule ^(.*)/portal\.(htm¦html¦php) http://mysite.com/$1/ [R=301,L]

jdMorgan

12:54 pm on Sep 22, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am trying to rewrite the following and having issues accomplishing it
[mysite.com...] (index page)
written as
[mysite.com...]

This isn't clear, especially the "written as" part.

In order to help you find a working solution to the right problem, we need to know:

What "index page" URL do you link to on your pages?
Which "index page" filepaths exist, and what is the URL used to access them?
How did you test?
What were the results?
How did the actual test results differ from those you expected?

Jim

flexxall

3:54 pm on Sep 22, 2009 (gmt 0)

10+ Year Member



If I type in my address bar
mysite.com
I get mysite.com but it is not picking up any css its just a blank page with unformatted text and what not.
when I type mysite.com.phpBB3
I get mysite.com/phpBB3/
which displays the main forum page
The sites home page is supposed to be a portal.php page located at mysite.com.phpBB3/portal.php
when I type that in my address bar I get the correct page.

My webserver is set up as web5/web/phpBB3/...
If I place an indel.html file into the web folder I will get that when i type in mysite.com in my address bar

When i replace the index.html file in the web folder with my .htaccess file and I type in mysite.com in the address bar i get the unformated page of the portal.php

Here is the current .htaccess file I am using

<Files "config.php">
Order Allow,Deny
Deny from All
</Files>

<Files "common.php">
Order Allow,Deny
Deny from All
</Files>
DirectoryIndex phpBB3/portal.php index.php index.html index.htm

jdMorgan

5:40 pm on Sep 22, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try:

DirectoryIndex /phpBB3/portal.php index.php index.html index.htm

Jim

flexxall

9:37 pm on Sep 22, 2009 (gmt 0)

10+ Year Member



That still returns the portal page with no formatting. Im confused :(

jdMorgan

1:32 am on Sep 23, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How are 'objects' such as images and css stylesheets linked-to from within the portal pages?

Because the URL and the filepath are different, you will probably need to link to them using a server-relative URL-path or a canonical URL, and not with a page-relative URL-path. That is, use <link rel="stylesheet" type="text/css" href="/path-to-stylesheet.css"> or <link rel="stylesheet" type="text/css" href="http://example.com/path-to-stylesheet.css">, and not <link rel="stylesheet" type="text/css" href="path-to-stylesheet.css">

Other than that, I suppose you could just rewrite *all* URL-requests to the /phpBB3 subdirectory, but then one has to ask, why not simply install the board in the root directory to begin with?

To rewrite all requests, you'll need something like this:


RewriteCond $1 !^phpBB3/
RewriteRule ^(.*)$ /phpBB3/$1 [L]

The RewriteCond prevents the rewriting from happening more than once, and thus prevents an 'infinite' rewriting loop.

If you use this rule, I think you'll need to change DirectoryIndex to "portal.php".

You may wish to exclude certain other paths from being rewritten. For example, if robots.txt is located in the top-level directory, and you don't want to move it to the/phpBB3 subdirectory, you'd need to add an exclusion for it:


RewriteCond $1 !^robots\.txt$

Jim

flexxall

1:35 pm on Sep 23, 2009 (gmt 0)

10+ Year Member



Ok, I went with the rewrite cond and that has worked just fine. Thank you for that. now is there a way to remove the /phpbb3/ from the address line of the pages ?

jdMorgan

1:48 pm on Sep 23, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, edit the script, database, or the pages (as appropriate) and change the linked URLs. The URLs you see in your browser address bar (and status bar) are solely determined by the URLs that you "publish" in the HTML on your pages, and as this occurs within the browser, no server-side code can affect it.

To be clear, URLs are created and defined in the HTML of Web pages. They "exist" as soon as you refer to them in the HTML of a published page. This is regardless of whether they will actually resolve to a resource on a server somewhere if they are "followed" or "clicked."

Jim

flexxall

11:31 am on Sep 25, 2009 (gmt 0)

10+ Year Member



Ok so i believe your saying if i set the path of the pages to blah/phpbb/ instead of just blah/ that should remove the requested phpbb from the browser request is I also ammend the page calls. I think that makes sence. Thank you for all the help :)

jdMorgan

12:55 pm on Sep 25, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Once you get those on-page links corrected, then (and only then) you can add a redirect to help 'clean up' any current search engine listings that point to example.com/phpBB3/<whatever> as a URL. In order to avoid an 'infinite' rewrite/redirect loop while doing that, it is necessary to check that the request came from a client, and is not the result of your internal rewrite rule's action. One way to do that is to use a RewriteCond to test THE_REQUEST to detect direct client requests. There are lots of threads on that subject here.

Jim