Avatar of EEssam
EEssam asked on

file.php to file.html

Hello,

I'm deveopling a simple app on localhost and I want to use mod_rewrite and .htaccess to be able call file.html while it's real name is file.php. I have a lot of files on the directory so I think it would be useful to have a command covering all the files.

Thanks.
Apache Web Server

Avatar of undefined
Last Comment
ravenpl

8/22/2022 - Mon
ASKER
EEssam

I currently have the following:

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^(.*).html /$1.php [R=301,L]

However, I'm getting the following error when I request file.html

Not Found

The requested URL /file.php was not found on this server.

And I should create file.php write under www directory to have it found (http://localhost/file.php) while I'm working in a folder and the file path is (http://localhost/project/file.php)

Please help.
ravenpl

Try

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*).html $1.php [R=301,L]
ASKER
EEssam

I was redirected to:

http://localhost/C:/wamp/www/XXX/file.php

And got the following error message:

Forbidden

You don't have permission to access /C:/wamp/www/XXX/file.php on this server.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER CERTIFIED SOLUTION
ravenpl

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question