Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rewrite www.domain.com/test.php to www.domain.com/test/

Okay, I'm a complete noob when it comes to editing .htaccess. I've never messed with it in all my years of building websites, and recently when trying to understand the process that goes into creating exactly what I'm looking for, it flies right over my head.

  • What I am trying to do is make a link domain.com/test/ load domain.com/test.php but keep /test/ instead of changing to /test.php

  • So I load domain.com/test/ and I see the page domain.com/test.php but the address bar shows domain.com/test/

If anyone could help me with this that would be amazing.

like image 466
user1379229 Avatar asked Dec 06 '25 15:12

user1379229


1 Answers

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
RewriteBase /

RewriteRule ^test/?$ test.php [L,NC]
like image 62
anubhava Avatar answered Dec 09 '25 18:12

anubhava



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!