1

I have been trying to figure urlrewriting out. And i am still not really getting it i think. So i tried this:

Options -Indexes +ExecCGI
AddHandler cgi-script .cgi .pl
php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
php_flag  log_errors on
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^home/? index.php
RewriteRule ^forum/?$ forum.php [L,NC]
RewriteRule ^forum/([a-z0-9-]+)/?$ forum.php?catagory=$1 [L,QSA,NC]
RewriteRule ^login/? loginpage.php
RewriteRule ^register/? registerpage.php
RewriteRule ^servers/? servers.php
RewriteRule ^profile/? profile.php
RewriteRule ^profile/([A-Za-z0-9-]+)/?$   profile?user=$1
RewriteRule ^members/? memebers.php

And i clearly did not work, my page won't even load normal any more

When i use the normal url:

forum/?catagory=test

And this works very good and will show me everything. I don't get why the url rewriting is not working! Even tried a generator and some things else. It won't work

Sjenkie
  • 207
  • 2
  • 3
  • 14

2 Answers2

2

Turn MultiViews option off:

Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^forum/?$ forum.php [L,NC]
RewriteRule ^forum/([a-z0-9-]+)/?$ forum.php?catagory=$1 [L,QSA,NC]

Option MultiViews is used by Apache's content negotiation module that runs before mod_rewrite and and makes Apache server match extensions of files. So /file can be in URL but it will serve /file.php.

anubhava
  • 761,203
  • 64
  • 569
  • 643
  • I added my whole .htacces in the question. The page test.com/forum/test does not work. I get this: http://prntscr.com/5drsb8. I should get something like this: http://prntscr.com/5drsg3 – Sjenkie Dec 06 '14 at 11:01
  • ok looks like problem is not getting your css/js. That is due to your use of relative links for css/js/images. You can try adding this in your page's HTML header: `` so that every relative URL is resolved from that URL and not the current page's URL. – anubhava Dec 06 '14 at 11:06
  • I will try that! The only weird thing is, if i type it out normaly: "test.com/forum/?catagory=test" that works fine. – Sjenkie Dec 06 '14 at 11:08
  • It kind of did not work, you are right about that it is getting the css/js/pictures from the wrong thing: http://prntscr.com/5dru84 . But your answer didn't do the trick.. – Sjenkie Dec 06 '14 at 11:11
0

First, did you turn the RewriteEngine On? Second, does the rewrite module is enabled? Do a phpinfo(); to check it out and this answer.

This way:

RewriteEngine On
RewriteBase /
RewriteRule ^forum/?$ forum.php
RewriteRule ^forum/([A-Za-z0-9-]+)/?$ forum.php?catagory=$1 [L]

This page can help you: URL Rewriting for Beginners

Community
  • 1
  • 1
Annie Caron
  • 437
  • 1
  • 5
  • 15
  • I have the engine on and it is enabled: as is said that "/forum/?catagory=test" works. I tried your code, i still isn't working. – Sjenkie Dec 05 '14 at 16:21
  • Do you have an error output in your log that can help? – Annie Caron Dec 05 '14 at 16:22
  • Yes i do i get for everything i load an error that it is unable to load: "Failed to load resource: the server responded with a status of 404 (Not Found) " – Sjenkie Dec 06 '14 at 10:43