Page 1 of 1
htaccess help if you please
Posted: Sat Mar 19, 2011 11:36 am
by Torniquet
Hey guys,
I am having some trouble with my damned htaccess mod_rewrite for my forum.
I have looked over several tutorials and pages showing how to do this, but i still cant get it to work
my links are displayed like so.
Code: Select all
http://pbw/community/a_sub_forum-f7.html
where a_sub_forum is the title of the forum and -f7 is the forums id.
this is the htaccess file.
Code: Select all
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^project-blackwidow\.com
RewriteRule ^(.*)$ http://www.project-blackwidow.com/$1 [R=permanent,L]
RewriteRule ^(.*)\.html $1\.php
RewriteRule ^([a-zA-Z0-9_]+)-f([0-9]+)\.html /viewForum\.php?fid=$2
as far as i can understand, this should work... but its not ¬¬
can someone please explain to me why this is going pair shapped please lol. I am just receiving 404 object missing errors when i click the link.
much love x
Re: htaccess help if you please
Posted: Mon Mar 21, 2011 4:22 pm
by Xaleph
Wow, even i don`t understand what the hell is going on down there.
$1 is the REQUEST_URI, somehow, you change the $1.php to $1.html where the whole string is considered to be 1 variable.
Afterwards you regex your REQUEST_URI to alpha numeric, -f(numeric).html which should lead to viewForum.php and here you use $2.
Where did 2 come from?
Re: htaccess help if you please
Posted: Mon Mar 21, 2011 11:56 pm
by Torniquet
$2 is the forum id, read from the numeric part of the url.
$1 (of that url) is meant to be the alpha numeric section, which would be the forum name. the forum name has no bearing on the proccessed url which is why i use 'fid=$2'
i really have no clue as to what is going or what i am meant to be doing, but is something i want to get out the way in the early stages so i dont have to go back and fix it all later on.
does that make it abit easier to understand? lol x
Re: htaccess help if you please
Posted: Fri Mar 25, 2011 6:42 am
by Torniquet
Ok i eventually got it working
http://www.project-blackwidow.com/community/foruma!-
4/
where
foruma! is the forums name, and
4 is the forum id. server side is read as community/viewForum.php?fid=4
EDIT ~~
ok hopfully the above explains more of what i am doing, and hopfully someone wil be able to understand what is going on now... -.-
htaccess
Code: Select all
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^project-blackwidow\.com
RewriteRule ^(.*)$ http://www.project-blackwidow.com/$1 [R=permanent,L]
RewriteRule ^(.*)\.html $1\.php
RewriteRule ^community/(.*)-([0-9]+)/$ community/viewForum\.php?fid=$2
RewriteRule ^community/(.*)-([0-9]+)/postNew.html$ community/postNew\.php?fid=$2
when i go to the postnew page, I its now saying i have a 404 error...
but when i replace the ([0-9]+) with (.*) it goes to the page ok, but adds 2 much onto the query string at the end.
postNew.php?fid=24/postNew.php
(notice the /postNew.php at the end)
If you understand wth is going on, please post the solution ¬¬ lol. ta xx
Re: htaccess help if you please
Posted: Sat Mar 26, 2011 3:27 am
by Jackolantern
You may want to edit your post to say you are still having a problem right at the top. When I saw "I eventually got it working!", I thought you meant the whole issue was resolved and the rest of the post is that solution.
Unfortunately, I have little experience editing htaccess files besides simple edits for CakePHP and CodeIgnitor. However I don't want someone who could help to skip your post because they think the issue is resolved.
Re: htaccess help if you please
Posted: Sat Mar 26, 2011 12:21 pm
by PaxBritannia
I mostly use NginX as a webserver, because it runs a lot faster. So I don't really know much ht-access knowledge apart from some basic operations.
Sorry about that.
pax.