Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

virtous on "Writing a theme in the style of MVC"

$
0
0

Hello Wordpress community!

I'm tackling a task of writing a theme in the MVC style. The theme I'm working on is inspired by Laravel so a lot of the file and folder structures have been borrowed.

So the issue I'm having is that I need Wordpress to edit the .htaccess file from the functions.php file, if that's possible?

Consider the following url,

http://www.website.com/controller/method/params/

I need Wordpress to redirect this url to index.php?url=controller/method/params/
Essentially, everything after "www.website.com/" is the url parameter.

I have managed to solve this by manually editing the .htaccess file so that it looks like this

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteBase /

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

RewriteRule ^(.+)$ index.php?url=$1 [L]

RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

This seems to work. I can still access files like wp-login.php without the page breaking, and I have access to the url parameter. However, I don't want to manually change this file.

Is there a way for Wordpress to change this for me?

I should add that I've tried to do this with the WP_Rewrite object, but failed. Although I managed to add my custom rewrite rule to the object, it didn't apply to the htaccess.

Help is appreciated.


Viewing all articles
Browse latest Browse all 8245

Trending Articles