Current location: Hot Scripts Forums » Other Discussions » Web Servers » can someone help me figure out why this isn't working?


can someone help me figure out why this isn't working?

Reply
  #1 (permalink)  
Old 03-26-10, 03:40 PM
Dave6187 Dave6187 is offline
Newbie Coder
 
Join Date: Mar 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
can someone help me figure out why this isn't working?

Hey guys, I'm working on setting up a forum similar to this one. I've got all the files for it uploaded to my host, but I'm having trouble actually getting it to work.

The instructions that came with it are very vague, and are written for someone who has a dedicated server, which I do not. It wanted me to had a virtual host to the apache config file,with the document root set to a specific directory, with a couple url rewrites in it. specifically, I was to add something similar to this to the config file:

Code:
<VirtualHost *:80>
ServerName kawf.org

# ----- start cut here for plesk vhost.conf ----- #
DocumentRoot /usr/local/kawf/config

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteRule ^/(pics/.*|css/.*|robots.txt|favicon.ico|apple-touch-icon.png)$ /$1 [L]
    RewriteRule ^/(account|admin|tips)/.*$	/$1.php [L]
    RewriteRule ^/.*				/forums.php [L]
</IfModule>

<IfModule mod_php5.c>
    php_flag magic_quotes_gpc Off
</IfModule>

# Template engine has problems with UTF8. Force single byte charset
AddDefaultCharset ISO-8859-1
# ----- end cut here for plesk vhost.conf ----- #

</VirtualHost>
changing it a bit to fit my needs...., what's important are the rewrites and the document root being set to the /config/ directory. Now because I don't have a dedicated server, I established a subdomain, and set the root to the appropriate directory. then I wrote a .htaccess file with the following:

Code:
Options +FollowSymlinks
RewriteEngine On

RewriteRule ^(pics/.*|css/.*|robots.txt|favicon.ico|apple-touch-icon.png)$ - [L]
RewriteRule ^(account|admin|tips)/.*$ /$1.php [L]
RewriteRule ^(\.*)$ /forums.php [L]
RewriteRule /\.* /forums.php [L]


php_flag magic_quotes_gpc Off

AddDefaultCharset ISO-8859-1

#password-protect multiple files
AuthName "Restricted Area" 
AuthType Basic 
AuthUserFile /home/ridethev/.htpasswd 
AuthGroupFile /dev/null 
<Files setup.inc>
require valid-user
</Files>
<Files config.inc>
require valid-user
</Files>

the forums.php file is located within the config directory, and contains this code:
Code:
<?php
include('setup.inc');
include("$srcroot/user/main.php");
?>
and according to the setup documentation, I need to hit /create.phtml. it's not an actual file, but a script located within the afformentioned main.php. what's supposed to happen is forums.php is supposed to load main.php, see that I requested create.phtml, and then load a create.php file.

same with if I were to go to /forumname/postnumber, it would go through that file, find the appropriate forum pages, and load it.

but all i'm getting is a 404 error saying forums.php does not exist, when in fact, it does. if I reroute it to say test.php, and inside test.php I have a redirect script to google, it will redirect to google..

i'm really stumped here. Perhaps my url rewrites are wrong, I don't know. does anyone have any ideas?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 03-26-10, 03:51 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
Quote:
RewriteRule ^(\.*)$ /forums.php [L]
RewriteRule /\.* /forums.php [L]
I think the rules above are the problem. The first rule says send everything to /forums.php The second rule says send everything with a slash to the same file.

If I were you, I'd put the original .htaccess file back, then change it, one line at a time, until it works the way I wanted it to. RewriteRules can be difficult.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 03-26-10, 03:59 PM
Dave6187 Dave6187 is offline
Newbie Coder
 
Join Date: Mar 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
thanks, i've been able to get the other two lines to behave the way I wanted, which I understood as keeping those files/directories from being affected by the rewrite.

the trouble is, like I said, those rewrites were meant to be put in a httpd.conf file, so things needed to be changed a bit, if I just use

Code:
RewriteRule ^/.* /forums.php [L]
nothing happens, if I remove that slash like you are generally supposed to do for .htaccess things from what i've read I get a 500 error.

what should that line be doing, so I know what to expect/look for?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 03-26-10, 08:19 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
^ means the beginning of the string
/ is a slash
. is any character
* means 0 or more of the preceding (any) character

It's fine to put them in an .htaccess file, in fact, it's much safer than putting them in httpd.conf, where they may be overwritten by an upgrade, or anywhere else in the Plesk filesystem, because sometimes those files are recreated as well.

These links should connect you with everything you need

Apache mod_rewrite Introduction - Apache HTTP Server
Apache mod_rewrite - Apache HTTP Server
mod_rewrite - Apache HTTP Server

Moving to web servers ...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 03-27-10, 07:31 PM
Dave6187 Dave6187 is offline
Newbie Coder
 
Join Date: Mar 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
thanks, I think I figured out what i need to do. I need a rewrite rule that takes whatever page i'm requesting, and sends it to forums.php, like if I request index.html, it'll get sent as index.html/forums.php, or test becoming test/forums.php. how would I accomplish this? I tried a couple things, and ended up hitting a infinite loop
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 03-27-10, 07:44 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
Try these:

Code:
# CATCH EVERYTHING INTO B2EVO:
# The following will allow you to have URL right off the site root,
# using index.php as a stub but not showing it.
# This will add support for URLs like:  http://example.com/2006/08/29/post-title

# Redirect anything that's not an existing directory or file to index.php
#

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ index.php [L]
It's from an .htaccess file for a b2evolution blog. If it's a filename or directory, it won't do the rewrite.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 03-27-10, 11:28 PM
Dave6187 Dave6187 is offline
Newbie Coder
 
Join Date: Mar 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
not quite what I was looking for, although very useful. That takes the whole url, and rewrites it to the script if it's not a file, so if I went to

domainname.com/thisisnotarealpage.phtml, it becomes domainname.com/forums.php unless it's actually a page. I need something.

I need something that takes the page i'm trying to hit, and adds forums.php to the end of it, I'm assuming I need to set a variable via [REQUEST_URI] and right out the rewrite to (variable set)/forums.php

so if I went to domainname.com/somthing, it gets rewritten to domain.com/something/forums.php


sorry if this is confusing, I know what I need, i just don't know how to write it
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 03-27-10, 11:38 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
Quote:
so if I went to domainname.com/somthing, it gets rewritten to domain.com/something/forums.php
Try this

Code:
RewriteRule   ^(.*)$	$1/forums.php [L]
Not tested
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 03-28-10, 01:32 AM
Dave6187 Dave6187 is offline
Newbie Coder
 
Join Date: Mar 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
that gives me a 500 error for some reason...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #10 (permalink)  
Old 03-28-10, 07:03 AM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
The rule I sent was a modified version of one I'm using. What it's supposed to do is capture the entire request (for example - page.phtml) and then append /forums.php to it - so it would become page.phtml/forums.php.

You may also want to write it this way:

^(.*)\.phtml$ $1/forums.php - which should strip off the .phtml

RewriteRules can be tricky. Be patient, you'll get them working.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Make Rewrite Modul Working in Windows, cause .htaccess ist not working specialex Web Servers 5 04-09-08 12:07 PM
PHP include not working in echo statement mike_jandreau PHP 6 04-03-07 06:02 AM
calendar working until months changed bitesize JavaScript 1 01-13-04 02:50 PM


All times are GMT -5. The time now is 10:43 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.