By 1520gis
According to URL [1], I would like to hind the file path value in the map variable using apache .htaccess RewriteRule. Based on discussions [2] and [3], I want to keep the same URL as in [1], but hind the file path as in [4]. My first attempt is:
RewriteEngine On RewriteRule ^cgi-bin/qgis_mapserv.fcgi?map=([A-Za-z0-9]+)$ cgi-bin/qgis_mapserv.fcgi?map=/home/qgis/project/$1 [NC, QSA]
[1] http://localhost/cgi-bin/qgis_mapserv.fcgi?MAP=/home/qgis/project/qgisdatapostgis.qgs
[4] http://localhost/cgi-bin/qgis_mapserv.fcgi?MAP=qgisdatapostgis.qgs
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hello,
If I understand correctly want to rewrite the URL to hide the file path in the map parameter, is that right?
You can update your RewriteRule to achieve this.
The RewriteRule can be added to your .htaccess file and it would look like this:
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^MAP=([A-Za-z0-9]+)\.qgs$
RewriteRule ^cgi-bin/qgis_mapserv\.fcgi$ /cgi-bin/qgis_mapserv.fcgi?MAP=/home/qgis/project/%1.qgs [L]
These rules will rewrite the URL http://localhost/cgi-bin/qgis_mapserv.fcgi?MAP=qgisdatapostgis.qgs to http://localhost/cgi-bin/qgis_mapserv.fcgi?MAP=/home/qgis/project/qgisdatapostgis.qgs internally while keeping the original URL in the browser.
Now, when you access http://localhost/cgi-bin/qgis_mapserv.fcgi?MAP=qgisdatapostgis.qgs, Apache should rewrite the URL internally to include the full file path while keeping the short URL visible in the browser
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.