htaccess help if you please

Need help with an engine or coding not on the list? Need help with a game or the website and forums here? Direct all questions here.
Post Reply
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

htaccess help if you please

Post 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
New Site Coming Soon! Stay tuned :D
Xaleph
Posts: 897
Joined: Mon Feb 07, 2011 2:55 am

Re: htaccess help if you please

Post 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?
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: htaccess help if you please

Post 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
New Site Coming Soon! Stay tuned :D
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: htaccess help if you please

Post 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
New Site Coming Soon! Stay tuned :D
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: htaccess help if you please

Post 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.
The indelible lord of tl;dr
User avatar
PaxBritannia
Posts: 680
Joined: Sun Apr 18, 2010 1:54 pm

Re: htaccess help if you please

Post 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.
Post Reply

Return to “Advanced Help and Support”