Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
integrating MySQL query generated pages succesfully and mod_rewrite
#1
I've been using Get Simple for my company's website for a while now. I enjoy many of the features and plugins available with this CMS. However, I've had to work with it a bit to get MySQL to work with my site's item pages. By default, all of the pages created by the CMS are extentions of index.php. In order for my item pages using MySQL to work, I had to basically create a copy of index.php and call it item.php; within this file, instead of linking to the default template, it uses another template specifically for my item pages containing the queries.

This all actually works just fine, however, I'm not exactly sure how to get "pretty URLs" to work with this kind of set up. With "pretty URLs" enabled, my CMS generated pages are working as intended and get nice, clean URLs, but I tried modifying the .htaccess file to include a RewriteRule for my item pages, but it doesn't seem to work.

Basically using Get Simple's pretty URL option enabled:
www.url.com/index.php?id=slug becomes www.url.com/slug

I want my item pages to change from:
www.url.com/item.php?id=001234&pg=words-words-words

to

www.url.com/item/001234/words-words-words.html

Here is my .htaccess file:
Quote:# Use PHP5 as default
AddHandler application/x-httpd-php5 .php
AddDefaultCharset UTF-8
# File modified on Dec 5 11:28:31 2011 by server
# For security reasons, mod_php is not used on this server. Use a php.ini file for php directives
# php_value default_charset "UTF-8"

Options -Indexes
Options +FollowSymLinks

# blocks direct access to the XML files - they hold all the data!
<Files ~ "\.xml$">
Order allow,deny
Deny from all
Satisfy All
</Files>
<Files sitemap.xml>
Order allow,deny
Allow from all
Satisfy All
</Files>


RewriteEngine on

# Usually it RewriteBase is just '/', but
# replace it with your subdirectory path
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule /?([A-Za-z0-9_-]+)/?$ index.php?id=$1 [QSA,L]
RewriteRule ^/?item/([0-9]+)/([a-zA-Z0-9_]+).html$ item.php?id=$1&pg=$2 [QSA,L]

Attempting to use the rewritten URLs results in a 404 page, meaning I'm doing something wrong. Anyone have any ideas on how to fix this?
Reply
#2
Nice to meet you, antiquarium.

From what I see, the .htaccess rule itself should work properly; it should just be the order that it comes in the rule-set that is messing things up. Have you tried putting your new rules first before the default GetSimple ones like so?

Quote:RewriteBase /

RewriteRule ^/?item/([0-9]+)/([a-zA-Z0-9_]+).html$ item.php?id=$1&pg=$2 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule /?([A-Za-z0-9_-]+)/?$ index.php?id=$1 [QSA,L]
Reply
#3
Thank you so much! That did the trick, you saved me more endless hours of searching for a fix.
Reply




Users browsing this thread: 1 Guest(s)