Forum Moderators: phranque

Message Too Old, No Replies

.htaccess problem with FAQ on my forum

         

Diablotik

9:46 am on Oct 8, 2009 (gmt 0)

10+ Year Member



Hello,

I am not good at understanding this code and that's why I post this thread, I hope you will be able to help me out with my problem.

I am running a phpbb forum with modification that converts .php to .htm on the forum.
I understand that .htaccess is responsible for converting my links to .htm, everything works fine except my FAQ section.
The link should be in this format: http://forum.example.com/faq.htm#3 but it looks like that: http://forum.example.com/#3 and instead of moving to the question in FAQ section it redirects to main page of my forum.

My .htaccess looks like that at the moment:

RewriteEngine on

#RewriteBase /forum

RewriteRule ^cat([0-9]*)\.htm$ ./index.php?c=$1 [L,QSA]
RewriteRule ^(cat¦.*-cat)([0-9]*)\.htm$ ./index.php?c=$2 [L,QSA]
RewriteRule ^(u¦.*,u),([0-9]*)\.htm$ ./profile.php?mode=viewprofile&u=$2 [L,QSA]
RewriteRule ^(g¦.*,g),([0-9]*)\.htm$ ./groupcp.php?g=$2 [L,QSA]
#
RewriteRule ^(forum¦.*-vf)([0-9]+)-([0-9]+),([0-9]+)\.htm$ ./viewforum.php?f=$2&topicdays=$3&start=$4 [L,QSA]
RewriteRule ^(forum¦.*-vf)([0-9]+),([0-9]+)\.htm$ ./viewforum.php?f=$2&start=$3 [L,QSA]
RewriteRule ^(forum¦.*-vf)([0-9]+)\.htm$ ./viewforum.php?f=$2 [L,QSA]
RewriteRule tags/(.+)/([0-9]+)$ ./seotags.php?tag=$1&start=$2 [L,QSA]
RewriteRule tags/(.+)$ ./seotags.php?tag=$1 [L,QSA]
RewriteRule tags$ ./seotags.php [L,QSA]
RewriteRule ^prev_topic/([0-9]+)\.htm$ ./viewtopic.php?t=$1&view=previous [L,QSA]
RewriteRule ^next_topic/([0-9]+)\.htm$ ./viewtopic.php?t=$1&view=next [L,QSA]
#
#
RewriteRule ^(topics[0-9]*/)?(.*-vt)?([0-9]+)-([0-9]+)-([a-zA-Z]+),([0-9]+)\.htm$ ./viewtopic.php?t=$3&postdays=$4&postorder=$5&start=$6 [L,QSA]
RewriteRule ^(topics[0-9]*/)?(.*-vt)?([0-9]+)-([0-9]+)-([a-zA-Z]+)-([a-zA-Z0-9]+),([0-9]+)\.htm$ ./viewtopic.php?t=$3&start=$7&postdays=$4&postorder=$5&highlight=$6 [L,QSA]
#
RewriteRule ^(topics[0-9]*/)?(.*-vt)?([0-9]+),([0-9]+)\.htm$ ./viewtopic.php?t=$3&start=$4 [L,QSA]
RewriteRule ^(topics[0-9]*/)?(.*-vt)?([0-9]+)\.htm$ ./viewtopic.php?t=$3 [L,QSA]
RewriteRule ^postlink/([0-9]+)\.htm$ ./viewtopic.php?p=$1 [L,QSA]

RewriteRule ^search\.htm/authors/(.+),([0-9]+)$ ./search.php?search_author=$1&start=$2 [L,QSA]
#
RewriteRule ^search\.htm/([0-9a-z]+),([0-9]+)$ ./search.php?search_id=$1&start=$2 [L,QSA]
RewriteRule ^search\.htm/([0-9a-z]+)$ ./search.php?search_id=$1 [L,QSA]

#
#
RewriteRule ^members/([a-z]+)_([a-z]*)-([A-Za-z]+),([0-9]+)\.htm$ ./memberlist.php?letter=$2&mode=$1&order=$3&start=$4 [L,QSA]
RewriteRule ^members(\.htm¦/?)$ ./memberlist.php [L,QSA]

RewriteRule ^profiles/([0-9]+)\.htm$ ./profile.php?mode=viewprofile&u=$1 [L,QSA]

RewriteRule ^groups/?([0-9]*)(\.htm)?$ ./groupcp.php?g=$1 [L,QSA]
RewriteRule ^groups/?$ ./groupcp.php [L,QSA]

#
RewriteRule ^sitemap,([0-9]+)\.htm$ ./sitemap.php?offset=$1 [L,QSA]

RewriteRule ^topics([0-9]+)/?$ ./viewforum.php?f=$1.htm [L,QSA]
RewriteRule ^(topics¦postlink¦prev_topic¦next_topic)/?$ ./index.php [L,QSA]
RewriteRule ^profiles/?$ ./memberlist.php [L,QSA]

#htm to php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} (.*)\.htm
RewriteRule ^(.+)\.htm(\?.*)? $1.php$2 [E=WasHTML:yes]
RewriteCond %{ENV:WasHTML} ^yes$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)\.php(\?.*)? $1.htm$2
RewriteCond %{HTTP_HOST} ^www.forum.example.com(.*) [NC]
RewriteRule ^(.*)$ http://forum.example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^example.com(.*)
RewriteRule ^(.*)$ http://example.com/ [R=301,L]
RewriteCond %{HTTP_HOST} ^www.angliki.example.com.pl(.*)
RewriteRule ^(.*)$ http://example.com/ [R=301,L]

[edited by: jdMorgan at 1:02 pm (utc) on Oct. 8, 2009]
[edit reason] example.com [/edit]

g1smd

2:36 pm on Oct 8, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Rules in .htaccess cannot change links at all. It is your script that publishes links to the browser screen.

The rules in .htaccess take a URL request arriving at the server after the link is clicked and fetch content from a different location inside the server compared to the location that was suggested by the path part of the URL request.

There is waaay too much code there to be digested in one go, but I will note the following:

QSA is the default action for rules unless you specified a new query string already and need to re-append the original data. Several of your rules do not need the [QSA] flag.

The 'previous' and 'next' parameters are a source of Triplicate Content that will slowly kill your site indexing.

You should usually list your redirects before listing any rewrites to avoid internal path parts being exposed by a redirect.

RewriteCond %{HTTP_HOST} ^example.com(.*)
RewriteRule ^(.*)$ http://example.com/ [R=301,L]

There is no need to capture (.*) on the end of the host name, and the above rule is surely an infinite loop.

Diablotik

3:00 pm on Oct 8, 2009 (gmt 0)

10+ Year Member



Thanks for your reply,

Robots are told not to index 'previous' and 'next' so there will not be double/triple idexing issue.

---

RewriteCond %{HTTP_HOST} ^example.com(.*)
RewriteRule ^(.*)$ http://example.com/ [R=301,L]

This has been badly moderated. The code in original is:
RewriteCond %{HTTP_HOST} ^example.hosting.pl(.*)
RewriteRule ^(.*)$ http://example.com/ [R=301,L]

Is there still no need for (.*) ib the end of the hostname?