Ask Your Question
0

Can you restructure a URL that points to a directory into one that points to a PHP file through htaccess?

asked 2021-07-07 11:00:00 +0000

pufferfish gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-05-02 21:00:00 +0000

lakamha gravatar image

Yes, it is possible to restructure a URL that points to a directory into one that points to a PHP file through htaccess. Here's an example of how it can be done:

Assuming that you have a directory called "blog" and a file called "index.php" inside that directory, the URL would be:

http://www.example.com/blog/

To restructure the URL to point to the PHP file, you can use the following htaccess code:

RewriteEngine On RewriteRule ^blog/?$ blog/index.php [NC,L]

This code will redirect all requests for "http://www.example.com/blog/" to "http://www.example.com/blog/index.php". The [NC] flag makes the rewrite rule case-insensitive and the [L] flag tells htaccess to stop processing any rules after this one.

After applying this htaccess code, the URL structure would be:

http://www.example.com/blog/index.php

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-07-07 11:00:00 +0000

Seen: 10 times

Last updated: May 02 '21