URL rewrite disappears on an Virtual Machine in azure - iis

I have a virtual machine in Azure and on that machine I have a IIS installed. On that IIS I have installed the URL Rewrite module and redirect all HTTP calls to HTTPS.
The problem I am noticing is that my rule that I am creating is removed from time to time. Have anybody any clue to why this is happening and how I can do the redirection from HTTP to HTTPS instead in a way not using the URL rewrite module.
Thanks
/Magnus

Aaa I found it!
It seems that the URL rewrite is removed every time I deploy a new version, and the reason is that the URL rewrite information is saved in the web.config file on the server when I add it in the IIS Administration.
And it's not part of my web.config file that I deploy. So all I have to do is to add the XML added by the URL Rewrite module from the web.config file on the server to my web.config file in my project and the redirect will stay.

Related

When trying to access index.php it redirects to index and shows 404 page

Im using IIS and I recently installed a module called URL Rewrite 2.
I tried changing the way index.php shows in the url.
I wanted to change from http://localhost/index.php to http://localhost/index
I did that and it wasn't working so I reverted everything.
Now when I search for http://localhost/index.php it redirects me to http://localhost/index and shows a 404 page.
I don't have any web.config in the server folder. I even unnistalled URL Rewrite 2. Everything was working before I tried this.
If you are sure you have reverted everything the redirect might be cached in the browser, try clearing the cache (or using another browser).

I don't have .htaccess file for my magento installation. How to get .htaccess file to remove the "index.php" from URL

I don't have my .htaccess file for my magento installation which is by default present for all the fresh magento installation.
Now I have to remove "index.php" from my wesite url and found out htaccess file needs to be edited. But, there is no .htaccess file in my magento root folder.
Also, I have made a lot of changes to the website and don't want to do a fresh installation to get the .htaccess file.
Also, when I access my admin panel it also needs "index.php" in the URL.
Please, can someone help me with this.
To Remove the inde.php from the URL you need to enable Web Server Rewrites.
You can enable Web Server Rewrites suing below steps:
Login in Backend, from Top Navigation click on System >> Configuration >> Web
Select Use Web Server Rewrites to YES in Search Engines Optimization group.
If you need .htaccess file, you can donwload the compatible magento zip file and can use its .htaccess. There is no need to install magento for this.

Unable to enable Clean URLs in drupal 7 website after migration

Recently, I migrated my website from local machine to server machine. The website URL is http://www.example.com/myweb
I noticed that only front page is visible and other pages are showing 404 error.
After reading this answer, I got to know that this is happening because of clean URL module. I enabled RewriteBase myweb in .htaccess file but It doesn't work out. Finally I thought of disabling Clean URL temporary as told here. This works well.
Now I wanted to enabled it again. It is showing following error-
Clean URLs cannot be enabled.
Below is the screenshot-
I can see some directory permissions error in status report at admin/reports/status. Are these related to each other?
You need to change your Apache server setting on new server.
Enable 'LoadModule rewrite_module modules/mod_rewrite.so' line in httpd.conf file on your server and restart server
Check if .htaccess works and also check if you have AllowOverrides All in your virtualHost config in Apache.

Configure PhpStorm to use .htaccess

I added .htaccess (for rewriting URLs) in my project's root directory but it's not working. I checked twice, the same file is working fine in Eclipse.
How do I configure PhpStorm to use .htaccess?
Indeed, PHP's built-in web server will never fully support .htaccess features. Note: it is PHP's, it is NOT PHPStorm's built-in server.
But there is a way around.
Most of the time, rewrites are needed only to redirect all the nonstatic file queries to index.php. If you only need this, you can set the server's "router script" in PHPStorm run configuration to index.php.
After that, a modest hack in index.php to serve static files from the drive may speed things up.
Add to the very beginning of index.php:
if (preg_match('/\.(?:php|png|jpg|jpeg|gif|ico|css|js)\??.*$/',
$_SERVER["REQUEST_URI"]))
{
return false; // serve the requested resource as-is.
}
Do you use the same server/configuration when working with PhpStorm and Eclipse?
As it was explained in the comments, it has nothing to do with the IDE, but with the web server (Apache) and its configuration.
You can edit .htaccess with any editor, if this virtualhost/directory configuration has AllowOverride All, ModRewrite is enabled and your rewrite rules are correct, it will work just fine.
You need to ensure that your PHP files are served from the correctly configured web server.

URL Rewrite not working for *.mp4 file extension

I'm working on a DNN site, and I have a requirement to set up a URL rewrite to redirect incoming requests for a particular URL for an MP4 video to a different location. I can get it working if the incoming URL does not have the *.mp4 file extension, but if the extension is there, the redirect fails and I get a 404.
I set up the rewrite by modifying the SiteUrls.config file to add the following entry:
<RewriterRule>
<LookFor>.*VIDEOFILENAME.mp4(.*)</LookFor>
<SendTo>http://externalsite/video/VIDEOFILENAME.mp4$1</SendTo>
</RewriterRule>
The above configuration results in a 404 if you try to browse to mydnnsite/VIDEOFILENAME.mp4.
However, the following configuration works just fine if you try to browse to mydnnsite/VIDEOFILENAME (without the *.mp4 extension.)
<RewriterRule>
<LookFor>.*VIDEOFILENAME(.*)</LookFor>
<SendTo>http://externalsite/video/VIDEOFILENAME.mp4$1</SendTo>
</RewriterRule>
For whatever reason, the presence of the file extension is preventing the redirect from happening.
IIS is probably setup to route requests with an .mp4 extension to the static file handler, and it isn't getting to DNN to rewrite the request at all. You can look at the Handler Mappings configuration in IIS to see if there's a mapping for *.mp4.
Ideally you'd be doing that redirect in IIS, anyway, rather than sending it to DNN, just to redirect back out.

Resources