Samuel Stiles
Samuel Stiles

Reputation: 2186

Is this .htaccess rewrite even possible?

My co-worker is proposing a .htaccess rewrite rule to implement on our system. I'm not even sure if it's possible, and I want someone more educated than me on the subject to verify.

Here's the URL currently:

http://cms.phasesolutions.ca/themes/Default/page.php?slug=home

Here's how he wants it to show up:

http://cms.phasesolutions.ca/pages/home/

Is that possible? (where the variable for "?slug=", and the "Default" folder, are subject to change, depending which theme they're accessing and what slug they're specifying)

Let me know, thanks

Upvotes: 1

Views: 37

Answers (1)

anubhava
anubhava

Reputation: 786349

Posting a solution in case you need starting point.

Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On

# handles /Default/home/ to /themes/Default/page.php?slug=home
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$2.php -f
RewriteRule ^([^/]+)/([^/]+)/?$ /themes/$1/$2.php?slug=home [L,QSA]

Upvotes: 1

Related Questions