<base> and rewriting problem

New to mod_rewrite? This is a good place to start.

<base> and rewriting problem

Postby MartinKS » Thu Apr 16, 2009 3:10 pm

Hello,

I've been trying to get from

http://localhost/AMS/index.php?page=foo&id=bar
or

http://localhost/AMS/subsomain/index.php?page=foo
or

http://localhost/AMS/subsomain/index.php

to

http://localhost/AMS/subsomain/foo/bar
or

http://localhost/AMS/subdomain/foo
or

http://localhost/AMS/subdomain

More clearly, the input is the folder structure, the output index.php with a query string.

As of now I have the following mod_rewrite rules:

RewriteEngine On
RewriteRule ([a-z]+)/([0-9]+)/?$ index.php?p=$1&berichtid=$2 [QSA,L]
RewriteRule ([a-z]+)/?$ index.php?p=$1 [QSA,L]

and my <head> section looks like

<head>
<base href="http://localhost/AMS/" />
<link href="stijlblad.css" type="text/css" rel="stylesheet" />

with stijlblad.css in the /AMS folder.

Now I'm printing the GET variable for debugging purposes and I can see it picks the variables from the URL the way I want it (with /AMS/page and /AMS/page/id. However, if I go to /AMS it says p=php. I wonder wether my rules are correct or not.

The other problem is that my stylesheet isn't working, and I can't figure out why.

Thank you,

Martin Klein Schaarsberg
MartinKS
 
Posts: 2
Joined: Thu Apr 16, 2009 2:35 pm

Postby MartinKS » Fri Apr 17, 2009 1:59 am

With help from a friend I got the following .htaccess code:
Code: Select all
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z]+)/([0-9]+)$ index.php?p=$1&berichtid=$2 [QSA,L]
RewriteRule ^([a-z]+)$ index.php?p=$1 [L]


It turned out ik had set
AllowOverride None in httpd.conf
which may have been a problem too. It does work right now.
MartinKS
 
Posts: 2
Joined: Thu Apr 16, 2009 2:35 pm

Postby richardk » Fri Apr 17, 2009 8:35 am

I don't think you need
Code: Select all
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 15 guests

cron