How can I remove .php extension while using ISPCONFIG 3? - php

I'd need to remove the .php extension from the browser, I used to do it from apache2.conf in the last server I was running the website on, but on this new one I need to use ISPCONFIG3 and I don't know how to use set it to remove the .php extension, since the website was already running on a server which was rewriting the extension the links in the html are all without .php which obviously causes on this new one that pages are not loaded.
Many thanks in advance

You can solve this with mod_rewrite which is available by default in ISPconfig.
As admin you can add these RewriteRules on the Options tab of a web domain. But you can also store them in a .htaccess file together with the php files.
The needed rules are already explained nicely on put links without file extension (.php)

Related

Execute .php files code without adding .php after url [duplicate]

This question already has answers here:
Reference: mod_rewrite, URL rewriting and "pretty links" explained
(5 answers)
Closed last month.
Recently i have installed a script. After successfully install. I got in homepage . But then i face the real problem. In navigation or in any link whichever i click i get 404 error. I tried multiple time why getting this. A hour later i found out that, site homepage+ only admin area can be browse. But if i Were to visit other options like settings or sign up/in. Pages i have to manually add .php after urls.
Basically i have lots of this type of internAl code/links. That needs to have php extention after url. So is there any code or tricks to execute .php file without typing it manually? I am on shared hosting. I have access .htaccess file and apache.
Example: site.domain.com/admin/settings = error 404
But
site.domain.com/admin/settings.php
Successfully show settings page.
menu/internal url pointing direct page without .php at the end.
And most importantly i am completely noob in this programing. So any tricks would be great. Although i can edit settings file to add .php after each links, but that is really time consuming+ if i forget to add .php in code. I have to check all of them manually 🥲. Thanks in Advance.
if it's available on your shared hosting platform (it normally is) mod_rewrite could help you here.
See: Removing the .php extension with mod_rewrite
HTH :-)
You have to put *.php in pure php or configure the .htacesse.

mod rewrite - img paths without extensions

I am using mod rewrite to strip URL of the .php extension, but the client wants me to go even further and strip of extensions all src paths in <img>. Is this doable via .htaccess, or maybe php? The only way I can think of now is JS but he wants it server side.
Add a .htaccess file with the following line:
Options +MultiViews
Then you can access the files within a directory without the extension, as long as your filenames are unique it should work OK.
The .htaccess file should be placed at the lowest level within your file structure that you want this behaviour to occur.
This will work for all extension!

How do I allow php files to be loaded with different extension?

I have some PHP files like index.php, contact.php, etc.
I want to name the files with the extension .blah (i.e, index.blah, contact.blah, etc. )
Is there something I can add to .htaccess to get them to load properly?
have a look at your httpd.conf to see how mime type handling is done for .php files, and simply do the same thing for .blah, or use mod_rewrite to change urls ending in .blah to internal redirects to .php through an .htaccess file. Either way, Apache's documentation is going to have all the details.

How to hide .php file extension without using .htaccess?

I have a problem trying to hide .php extension from the url
I have been asked to hide it and because they are on a shared host i don't think i have access to .htacess so is there another way to hide it through a php function that i would call everytime an anchor is being selected?
Is this truly about hiding .php or is it more about having cleaner URLs?
If you truly can't access .htaccess (i.e. your host has this turned off via AllowOverride None) and assuming you also can't have your Apache conf settings updated for your VHost, the best you can do may be
http://example.com/page.php/my/clean/url
By default, Apache will send this URL to page.php even with everything else after it. This is the most common way of creating "cleaner" URLs without access to mod_rewrite.
.htaccess is what you would have access to on a shared server, as opposed to httpd.conf, which you wouldn't.
Put a .htaccess file in your document root with the following
FAIL
If your site stops loading, then you can use .htaccess :)
Of course, ^ that is a joke.

Accessing PHP Scripts Without .php Extension

How do you configure Apache and/or PHP to be able to access PHP scripts without the .php extension? I have seen PHP scripts executed without the .php extension. I don't mean executing 'script' as a PHP file, I mean executing 'domain.com/script' as a PHP file where 'script.php' exists as a file, but you are able to access it without using the extension. Does anybody know how to configure this?
I AM USING A CPANEL HOSTING!
WHERE TO WRITE THE mod_rewrite? I HAVE A .htaccess file with code # Do not remove this line or mod_rewrite rules and search engine friendly URLs will stop working RewriteBase /
Several basic ways:
Use MultiViews. Automatically converts /foo => /foo.php (among other things)
Use mod_rewrite to remove PHP extensions
Use mod_rewrite to direct all traffic to a single dispatcher script, which inspects the URL and performs the proper action by including files / calling class methods, etc.
Generally that's done in Apache via mod_rewrite.
Here's a guide: http://wettone.com/code/clean-urls
Such a rewriting doesn't make too much sense.
If you want (SEO-firiendly|human-readable) URLs, you have to use complete set of rewrite rules, not just removing extension.
Otherwise there would be no point in such a configuration change

Categories