Please login or register.

Login with username, password and session length
Advanced search  

News:

You need/want an older version of sNews ? Download an older/unsupported version here.

Author Topic: .htaccess rewritting problem  (Read 4395 times)

bensor

  • Newbie
  • *
  • Karma: 0
  • Posts: 6
.htaccess rewritting problem
« on: December 23, 2006, 01:58:54 am »

Hi,

I've asked several persons, posted on a few very visited both french and english discussion boards, I couldn't have an answer.

The thing I want is to rewrite all the requested url, excepted for images, javascript and css, to index.php with getting everything that's not real (for example, "subfolder" contains the file, I submit the url ".../subfolder/word1/word2" and I get the string "/word1/word2"). I succeeded for most cases. /basesite/~accountdir/subfolder/contact/view/id/1 redirect to /basesite/~accountdir/subfolder/index.php, but when I replace "contact" with the word "index" (per example : "/basesite/~accountdir/subfolder/index/a_word/again/and_again"), everything bug.

I get the rewritted URL with the "$_SERVER['REQUEST_URI']" from PHP. In the first case, I have "/contact/view/id/1", but with "index" I have "/~accountdir/subfolder/index/a_word/again/and_again". The code is included in "index.php", located into the "subfolder" directory, with the .htaccess file.

Here is my .htaccess file :
Code: [Select]
RewriteEngine on
RewriteBase /~accountdir/subfolder

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d


RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php
Does anyone see a solution?

Thanks.

EDIT : The code of index.php, to be clear :
Code: [Select]
  /*
  * Should return /keyword1/keyword2/keyword3, but returns
  * /folder/subfolder/index/keyword2/keyword3 with "folder"
  * at the root of the web directory and "index" as "keyword1"
  */

  echo $_SERVER['REQUEST_URI'];
?>
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
.htaccess rewritting problem
« Reply #1 on: December 23, 2006, 03:51:05 am »

Welcome bensor. What version of sNews are you running? The .htaccess script you show there is not what we use in sNews at all. But if you look in the RESOURCES Forum here, you will find some .HTACCESS resource links there that might help you with a non-sNews issue.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

bensor

  • Newbie
  • *
  • Karma: 0
  • Posts: 6
.htaccess rewritting problem
« Reply #2 on: December 23, 2006, 10:01:50 am »

Quote from: keyrocks
Welcome bensor. What version of sNews are you running? The .htaccess script you show there is not what we use in sNews at all. But if you look in the RESOURCES Forum here, you will find some .HTACCESS resource links there that might help you with a non-sNews issue.
Well I created this thread outside of the categories related to sNews ;) I posted on this forum because people here seem to know how to handle .htaccess files, and there's a possibility you'll find a solution about this problem :) I'm sorry if I did something wrong by asking here.

If there's nothing wrong, I'll continue ;) :

I've just discovered that the .htaccess doesn't work if the first keyword is the name of a file. I created a file called "inde.php". Then, I put "inde" as the first keyword and index.php wasn't called (nothing was returned onscreen). So I think I identified more precisely the problem.
Logged

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4867
  • I'm a self-made man and worships my creator.
    • p-ahlqvist.com
.htaccess rewritting problem
« Reply #3 on: December 23, 2006, 10:16:15 am »

Which probably means that you do not use sNews at all, right...

Well, welcome anyways, bensor... As we're sort of specialize on sNews and sNews issues here on the Solucija.com forums Key's kind of assumed you where using it.

I'm not a .htaccess "know'er" in any sense of the word (which i made up ;) ) so I wont try and answer. But I'm confident that someone will try and help you never the less...

Merry Christmas, and go download a copy of sNews, you hear ;)
Logged
"It's only dead fish that goes with the flow... "
Updated

bensor

  • Newbie
  • *
  • Karma: 0
  • Posts: 6
.htaccess rewritting problem
« Reply #4 on: December 23, 2006, 10:30:56 am »

Quote from: Patric
Which probably means that you do not use sNews at all, right...
Right  :)

Quote
I'm not a .htaccess "know'er" in any sense of the word (which i made up ;) ) so I wont try and answer. But I'm confident that someone will try and help you never the less...
I hope too :)

Quote
Merry Christmas, and go download a copy of sNews, you hear ;)
You too :) Maybe i'll download a copy of this app. But you know, the app I'm developping is an app who works like "Zend Framework", because I don't like to rely on the work of others when I know I can have the same results by myself :)
Logged

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
.htaccess rewritting problem
« Reply #5 on: December 23, 2006, 11:33:24 am »

Hey bensor,
This is probably of no help, and you've probably seen it already, but -- have you tried this page?

Sorry I can't help you more. 'tis the season to be jolly, after all.
Logged

bensor

  • Newbie
  • *
  • Karma: 0
  • Posts: 6
.htaccess rewritting problem
« Reply #6 on: December 23, 2006, 11:43:03 am »

Quote from: agentsmith
Hey bensor,
This is probably of no help, and you've probably seen it already, but -- have you tried this page?

Sorry I can't help you more. 'tis the season to be jolly, after all.
I didn't know this website (added to my favorites, just in case). Thanks, but it's no help at all :( The results I get are the same that the things I tried
Logged

bensor

  • Newbie
  • *
  • Karma: 0
  • Posts: 6
.htaccess rewritting problem
« Reply #7 on: December 23, 2006, 01:53:48 pm »

Problem solved : in the apache conf file, "AllowOverride" was not configured so that existing files could be ignored for keywords which were the same as them
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
.htaccess rewritting problem
« Reply #8 on: December 23, 2006, 03:11:29 pm »

Glad you found it. This is where we would have started on troubleshooting it... checking the Apache configuration to make sure all of the right modules were enabled... also check to ensure that Apache's mod_rewrite module is enabled in the httpd.conf file... usually around line 118 in Apache versions released after July 2006. BTW... are you running Apache (etc) as a bundle on your own machine... or dealing with it on your host's server?
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

bensor

  • Newbie
  • *
  • Karma: 0
  • Posts: 6
.htaccess rewritting problem
« Reply #9 on: December 23, 2006, 03:35:26 pm »

Quote from: keyrocks
Glad you found it. This is where we would have started on troubleshooting it... checking the Apache configuration to make sure all of the right modules were enabled... also check to ensure that Apache's mod_rewrite module is enabled in the httpd.conf file...
The weird thing is that in all the forums or all the persons I talked about my problem, NONE of them thought about that
Quote
are you running Apache (etc) as a bundle on your own machine... or dealing with it on your host's server?
For devellopping the app, I'm working on my own machine. Once it's ready (very soon, it's a matter of hours since i've already worked on it before discovering this problem), i'll use it as a website on a host (i'm thinking about this one)
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
.htaccess rewritting problem
« Reply #10 on: December 24, 2006, 02:40:37 am »

I develop offline on my own machine too... XP with the XAMPP Apache/PHP/MySQL (etc.) bundle. I haven't used Dreamhost but I think others sNoozers here have or are. (I host myself and others). Best of the Holiday Season to you bensor (if you celebrate it). :)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU