URL Rewrite on a single page with .htaccess?

Permalink 1 user found helpful
Say you have a single page located athttp://www.mysite.com/helloworld and you want to place a rewrite rule on that "page". Any rule. How do you go about it?
Considering concrete attaches a real url such aswww.www.mysite.com/index.php?cID=78,... and considering that the represented hellworld.php placed within the single_pages directory isn't accessible via url (meaning you can't type inwww.www.mysite.com/hellword.php)... how could one conduct a rewrite?

It's obvious there is some sort of aliasing or rewriting already going on to achieve /helloworld/ vs the "ugly" url the cms captures. Has anyone been able to accomplish this task and if so how?

View Replies: View Best Answer
ijessup replied on at Permalink Reply
I'm not quiet sure I understand what you are trying to accomplish.

Or rather, what I'm trying to figure out is what do you need to use the .htaccess file for, specifically?

I'm no .htaccess expert, but I was under the impression they are used for overriding the Apache defaults for a particular folder.

Granted, what you want to do may be possible by adding a few lines to the .htaccess file, why not just change the name of the php file?
ScottC replied on at Permalink Reply
ah basically this is kind of a bit tricky, but not too bad since you want it to go in one place. Sorry i haven't written the code for this actually ever, but here's what you want to do;

mod_rewrite rewrites the url to the singlepage say


clients is a single page, but you want to load these from the db, so you think you can do


sid.com/clients/ with clients as the singlepage and having an applicable controller, unless it has a method called apple(hugely stupid and besides the entire point) , you'd want to do something like:

ClientsController extends Controller

function client($clientID = ""){
//act on $clientID

but your mod_rewrite will want to rewrite the url to sid.com/clients/client/apple or

side.com/clients/-/client/apple if you are using legacy urls

Wildcarding on the "apple" chopped regex match
sid replied on at Permalink Best Answer Reply
Hey thanks for the quick replies! I've got it hashed out now.
I may not have explained it well enough but I was having an issue getting additional mod_rewrite rules to work on anything no matter where I placed the .htaccess file. I have pretty url enabled and the rules for it were first in my .htaccess file and canceling out the rules I was adding.
So the fix was to place my rewrite rules above the rules for pretty url.
I'm creating urls that pass page parameters that gets interpreted as a query. For example:

http://www.mysite.com/users/bob translates underneath to

This way a user won't have to remember that crazy query url but only the "pretty" one.

I've implemented like so incase anyone wants to do this.

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule ^users/([a-zA-Z_]+)$ index.php?cID=23&profile=$1 [QSA] 
Options +FollowSymlinks
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

And within the "users.php" single page just drop a
snippet and do as you wish with the returned value which should equal bob. Or to stay within the concrete5 way of doing things (which i recommend) create a controller that retrieves that variable and handle it that way.

Hope this helps someone! Took me hours to realize I needed to reverse the order of rules in that .htaccess file.
cursal replied on at Permalink Reply
Same sort of question so I thought I would stay in the same thread....

I have redesigned a site using concrete5 and was doing the 301 redirects to all the new pages when I hit an error.

All previous pages were .htm (old site)EXCEPT the contact page which was .php

when I 301'ed the old via
301 redirect /contact.php
It gave an internal server error 500

how do I redirect that old .php url to the new one?

Note: I am NOT using single pages in any of this.
sid replied on at Permalink Reply
Well I'm not sure how you've written your rules within your .htaccess file but it should be something like the following..

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.html$ $1.php [R=301,L]

It shouldn't matter if you have had mixed file types before as the rule just forces anything that was .html to .php if it isn't already. It also shouldn't matter if it's a single page or not.

Also be sure to stick the rules above the rules for the pretty url code if you have that enabled and running to avoid conflict.
cursal replied on at Permalink Reply
yep pretty urls was my culprit.
Once I saw that I got it working just fine.