Jump to content

Stuck with pretty URLs


insidus

Recommended Posts

Im trying to get my head around pretty URLs, but i just can't seem to grasp it.

 

.htaccess

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f

RewriteRule ^pretty/([0-9])$ pretty?id=$1 [L]

 

pretty.php

<?php
echo $_GET['id'];
?>
<h1>hi</h1>

 

if i go to http://.....co.uk/pretty  it prints "Hi" and an error cause the GET isn't set,

it does the same if i go to .co.uk/pretty/2

 

How does one use pretty urls within a site?

 

i ready hundreds of sites/tutorials on this, and nothing says how you GET the data from the url

 

.co.uk/pretty.php?id=2 works

Link to comment
Share on other sites

Turns out, i needed to include -MultiViews in the .htaccess file to get that bit working, but now for my production site, if i do

RewriteRule ^view_job/([0-9]+)$ ./view_job.php?job_id=$1 [L]

 

It loads the page, with the correct 'job', but it doesnt load the CSS file? :(

 

surely its not needed to make a rewrite to the css aswell?

 

Link to comment
Share on other sites

You have this bit in there right?

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

 

This will exclude files and directories that physically exist from being rewritten.

 

Also, make sure you are using absolute paths to the CSS file including the domain name.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.