pug-php / pug

Pug template engine for PHP
https://www.phug-lang.com
MIT License
391 stars 42 forks source link

Routes htaccess #181

Closed Escarnope closed 6 years ago

Escarnope commented 6 years ago

I am using the index.php and .htaccess from the "example" folder

I was wondering, how could I get the URLs from

https://site.com/index.php/page to https://site.com/page

kylekatarnls commented 6 years ago

Hi, the example directory is live here: http://pug-example.selfbuild.fr/ and use the same .htaccess, as you can see, with no special changes, the URL rewriting is working.

Are local .htaccess and rewrite modules enabled on your machine?

Escarnope commented 6 years ago

Yeah they're enabled, they just don't seem to be working properly.

When I go to /page, it just shows the index page

kylekatarnls commented 6 years ago

Hum, maybe you have other redirections rules (in your vhost, or main apache config)?

Could you dump $_SERVER['PATH_INFO'] for debugging?

Escarnope commented 6 years ago

On /page : Undefined index: PATH_INFO On index.php/page : /page

kylekatarnls commented 6 years ago

That's the difference (I get /page for both).

Hum, there are my apache options for the demo vhos: Options -Indexes +FollowSymLinks +MultiViews

Could you try to add each of +FollowSymLinks and +MultiViews to see if its help. I will inspect what can influence PATH_INFO, php version maybe.

Escarnope commented 6 years ago

I'm using PHP 7.1.12

And this is the .htaccess

Options -Indexes +FollowSymLinks +MultiViews
<IfModule mod_rewrite.c>

    # Activate the rewrite engine.
    RewriteEngine On

    # If the path matches a file.
    RewriteCond %{REQUEST_FILENAME} -f
    # Then, return this file.
    RewriteRule ^ - [L]

    # Redirect any other request on index.php with the request URI as path info.
    RewriteRule ^(.*)$ /index.php/$1 [L]

</IfModule>
kylekatarnls commented 6 years ago

Maybe try this: RewriteRule (.*) index.php [QSA,L,E=PATH_INFO:/$1]

Source: https://stackoverflow.com/questions/8497404/php-serverpath-info-and-apache-mod-rewrite

Escarnope commented 6 years ago

Still not working

kylekatarnls commented 6 years ago

I have the same PHP version. And what is your Apache version? Is your site in a directory URL (http://site.com/directory)? Maybe you could upload a live example.

kylekatarnls commented 6 years ago

Maybe you could check this flag that can erase the PATH_INFO: https://httpd.apache.org/docs/2.4/rewrite/flags.html#flag_dpi

kylekatarnls commented 6 years ago

Hi, as I can't reproduce, I close this. If you have new information to debug, feel free to reopen.