Floris
Floris

Reputation: 41

.htaccess filename to url

I've been searching and cannot find an answer that suits my needs. It is a rather simple question I assume.

The point is that I need to rewrite my files to a name of my liking. For example I have, 'www.mydomain.com/account_index.php' which I want to rewrite to www.mydomain.com/account

Thus far I had this, but that doesn't seem to work with multiple lines.

Rewriteengine on
rewriterule ^support account_ticket.php [L]
rewriterule ^account account_index.php [L]

So in short, I want my website to redirect /account to account_index.php and the other way around.

Thanks in advance!

Upvotes: 2

Views: 156

Answers (1)

Floris
Floris

Reputation: 41

I found the answer for those that are wondering. I had to put a RewriteCond before every RewriteRule.

So if I wanted to go to www.mydomain.com/account. I'd have this:

RewriteCond %{REQUEST_URI} ^/account$ [NC]
RewriteRule ^account account_index.php [NC,L]

This means that /account is now linked to account_index.php.

Have a nice day!

Upvotes: 1

Related Questions