.htaccess foobar.html -> foobar.php - .htaccess

i have to edit an existing web project. This project has only html pages and links to html pages.
Ex. from foobar.html is a link to bar.html.
Now I have to edit several pages and change the url to bar.php.
I dont want to change every

Put a Redirect directive for each one you need to remap in your .htaccess file.
Redirect /junk.html http://yoursite.com/junk.php permanent
Redirect /junk2.html http://yoursite.com/junk.php permanent

Take a look at sed, awk, python to edit/replace the strings your file. In this order ;)
(see: Unix or Cygwin)

Related

I can't find htaccess in typo3

I am using Typo3 4.5., and am running into the problem which appears to be solved here: TYPO3 breaks urls without WWW ... (website redirects to index without WWW)
The answer recommended there involves editing the htaccess file.
My problem is I cannot find this file anywhere. I am not experienced with Typo3, how can I safely edit this document?
I have gone into my filelist and found an htaccess file at [fileadmin/]: temp/ but I cannot edit this document. Clicking on it gives me an error 403 in a new window. In german nonetheless.
Even the question is related to a very old TYPO3 version I want to answer here for the current version 9.5 where several .htaccess files are saved in the folder
typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/
These are the files in that folder:
fileadmin-temp-htaccess
fileadmin-temp-index.html
fileadmin-user_upload-temp-importexport-htaccess
root-htaccess
root-web-config
typo3temp-var-htaccess
All files with htaccess at the end (above bold text) should be used according to the filename, copied in the corresponding directory and each copy then renamed to .htaccess.
The other files should be used too according to name and content.
It has to be considered that .htaccess-files perhaps are not exchangeable always between TYPO3 versions; I never had problems with it during many updates but it should always be checked.
The .htaccess file is a hidden file and is located in the document root of your website. This file can't be edited from inside of TYPO3, you need direct access to the webserver (ssh, sftp, ...)
If you installed TYPO3 from the "dummy package", it should have a "_.htaccess" file in the root that must be renamed. As the previous answer by #M Klein told you, you must rename or edit it by direct access to your server.
Another possibility is that the file has been accidentally removed; in this case you could download the "dummy package" (select your TYPO3 version) and pick a new one from there.

How to remove number in any url address in specific folder .htaccess

I want to remove numbers on the end url in specified folder, using htaccess.
(Numbers and minus sign befor numbers). For all urls in this folder.
For example
http://www.example.com/music/new-track-released-52
or
http://www.example.com/music/helo-there-4
Need to look like
http://www.example.com/music/new-track-released
http://www.example.com/music/helo-there
For all links in folder music
(I'm already removed php extension with htaccess)
How to do that?
Probably something like this:
RewriteEngine on
RewriteRule ^/music/(.+)-[0-9]+$ /music/$1
Note that this is the version for the host configuration. For .htaccess style files this has to be slightly modified. Whenever possible you should prefer not to use .htaccess style files but the real host configuration instead. Those files are notoriously error prone, hard to debug and really slow the server down.

No php.ini file

I'm making a PHP form that requests a file for download. I've had an error with the script and did some searching found out that it was because my php.ini file needed allow_url_fopen = On, so I went to change the settings and my site has no php.ini file. I couldn't really find out how to make a php.ini file. How would I create this file? My web host says I need to create it. What are the default settings to put into this file?
First, try to figure out, whether you really don't have the file. The php.ini location can be found in phpinfo(); output.
Second, if there is such file, edit that one. If not, download the ZIP package from php.net and there is at least php.ini.recommended, which contains basic directives.
Well, if you have no php.ini file, you can create it with as few lines in it as you need. Just put allow_url_fopen = On on an ascii file and name it php.ini, copy it to the working directory or the public root. Take in mind that anyway this values can be overrided by hosting's staff in places where you do not have access. To see what is the final and actual setting that aplies use phpinfo().
A side note: .htaccess files can in some circunstances govern and override php settings, so also take a look on all of them (that are accesible to you) to see if you can set your preferences there. Be careful that systax differs from php.ini .htaccess example

Customize default directory display using .htaccess

I want to customize the default listing of directory including the header and footer of the page. I tried to search this information however most of the information included how to disable the access to directories or provide the access to directories. My concern is to change the font, include some images in header(i.e change the layout of the page as it displays by default and also put a logout option)with directories being displayed.
any help would be highly appreciated!
I think this post might be helpful:
http://perishablepress.com/better-default-directory-views-with-htaccess/
Although, you mention above that you need to add a logout option as well, which means there will need to be some backend coding. What programming language are you using? It would be much easier to use the backend language (like PHP, .Net, Java, etc) to grab the contents of the files/directories, that way you have full control. .htaccess files are nice, but with what you're trying to do, it seems to involve much more than the capabilities of only strictly using .htaccess files.
Either way, the post above should help you "change the font, include some images in the header and change the layout of the page", just not allow the login/logout.

Font embedding and .htaccess in Firefox

Check out http://fube.ca in any browser but Firefox and you'll see that the cloud logo is a custom glyph font. In Firefox, though, the font won't load.
As best I can gather, the problem is that I'm serving the font from a subdomain and Firefox has strict requirements about the serving fonts from the exact same domain as the site. Apparently I can get around this by making a change to my .htaccess file, but the recommended changes don't seem to be working. See https://www.fontspring.com/support/troubleshooting/webfonts-are-not-loading-in-firefox and http://enable-cors.org.
Based on what I gather from these, here is what my .htaccess file currently looks like:
AddHandler php-stable .php
Header set Access-Control-Allow-Origin "*"
The first line was already there. I added the second (blank) and third lines. What am I doing wrong?
Actually, it turns out that my changes to .htaccess didn't save somehow. Adding that line to .htaccess does fix the problem.

Resources