how to use .htaccess with PHPDesktop? - phpdesktop

I'm trying to get my .htaccess file to work with PHPDesktop, but .htaccess doesn't seem to work. I saw that it's possible to hide specific files in the settings.json file, but it seems pretty limited. Is there a way to use my .htaccess file instead of using the settings.json file? Here's what I use for my .htaccess file:
RewriteEngine On
RewriteRule ^public/(.+) public/$1 [END] # allow direct access on public folder
RewriteRule ^ index.php [END] # anything else will be directed to index.php

No, you can't use .htaccess with PHP Desktop. PHP Desktop embeds a Mongoose web server which doesn't support such configuration file.
The rewrite rules from your .htaccess can be handled by setting web_server > 404_handler in settings.json file to /index.php.

Related

hide the actual name of a file inside a folder using .htaccess file

suppose, I have an index100.php file inside folder1 (eg. folder1/index100.php). Is there any way so that if the user types folder1/index.php, then it will automatically redirect to folder1/index100.php?
How can it be done using .htaccess file?
If you want to show index100.php insted of index.php as your directory handler, you can use DirectoryIndex directive in /folder1htaccess
DirectoryIndex index100.php
This will serve you the /index100.php if you visit http://example.com/folder1
If you actually want to redirect /folder1/index.php to /folder1/index100.php then use the following rule in your /folder1/. htaccess .
RewriteEngine on
RewriteRule ^index\.php$ /folder1/index100.php [L,R]

Symfony .htaccess

I configured a test folder for websites in hostgator, so far I have no problems in some flatform like wordpress,magento,joomla, I did not even change any seetings in .htaccess to make it run. Recently, I am working on a symfony2 project and upload my test application in the test folder I created. This is how I create a test folder
mywebsite.com/tests/wordpress_site(no problem)
mywebsite.com/tests/joomla_site(no problem)
mywebsite.com/tests/symfony2_site(403 forbidden error)
In my WAMP, I can accessed my symfony project
localhost/symfony_site/web/
I did not touch the .htaccess since this is just a test site in local machine.
How would you configure a symfony2 project in this setup?
mywebsite.com/tests/symfony_site
It is almost impossible to create clean Urls when installing symfony in subfolder...
With Apache, the better solution is to use a VirtualHost which have tests/symfony_site/web as DocumentRoot, and to use the built-in .htaccess file (which uses url rewriting module, or if it not available, uses a 302 redirection to app.php/)
But If you can't add a virtualHost to your server, it is hard...
An other way is to add a .htaccess at tests/symfony_site and put DirectoryIndex: web/app.php
(https://httpd.apache.org/docs/current/mod/mod_dir.html)
So you can have clean URLs... but be careful with this solution: the urls parsed by the router are relative to your site root (and not to symfony root...) so the router might be lost... (e.g if you have a root named /test you should rename it /tests/symfony_site/test... And it is the same for assets, you have to add the site directory, otherwise they will return a 404 error...
In my case, I just use existing .htaccess in web folder (or I create a new one with a DirectoryIndex Instead), so my app work with URLs like mywebsite.com/tests/symfony_site/web/
I hope this helped,
Vincent
You can try typing the following code into the .htaccess file to the symfony root folder
RewriteEngine On
RewriteBase /
RewriteCond $1 !^(img|files|images|favicon.ico|css|js|robots\.txt)
RewriteRule ^(.*)$ web/$1 [L]
RewriteCond %{HTTP_HOST} host.com
RewriteCond %{REQUEST_URI} !web/
RewriteRule ^(.*)$ web/$1 [L]

Rewrite rule .htaccess for my sitemap.xml

I have a content management system plugin installed that provides a sitemap for Google under http://www.domain.com/index.php?eID=dd_googlesitemap how can I add a rewrite rule to my .htaccess that will make this sitemap available under http://www.domain.com/sitemap.xml instead?
You can add this code to your htaccess file (which has to be in root folder)
RewriteEngine On
RewriteRule ^sitemap\.xml$ /index.php?eID=dd_googlesitemap [L]
Make sure mod_rewrite is enabled

htaccess redirection rule

I want to redirect
http://subdom.domain.com/guidelines/article1
http://subdom.domain.com/guidelines/article2
http://subdom.domain.com/guidelines/article3
to
http://subdom.domain.com/notsoguideline/noarticlepage/blahblah
so I wrote the following rule in .htaccess of my wordpress site but it doesn't seem to work
RewriteRule ^guidelines/([^/]+)/ /notsoguideline/noarticlepage/blahblah/
Check that your hosting supports and allows the use of .htaccess files.
Ensure that you have RewriteEngine On in your .htaccess (before your custom rules)
If you create a nonsense .htaccess file what happens? If nothing then your .htaccess file is not in use.

How to redirect any folders within a subdirectory to a specific file using htaccess?

I want to redirect any folder to a specific php file with the folder name as variable using htaccess, for example:
www.domain.com/subdirectory/folder1 redirects to www.domain.com/subdirectory/file.php?id=folder1
www.domain.com/subdirectory/folder2 redirects to www.domain.com/subdirectory/file.php?id=folder2
This should work if the folders have "/" at their end, for example,
www.domain.com/subdirectory/folder3/ redirects to www.domain.com/subdirectory/file.php?id=folder3
It will be better if I can put the .htaccess file in the subdirectory and get redirect rule according to it.
I created a .htaccess file with the following code while putting the file in the subdirectory:
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*)$ file.php?id=$1
but it does not work.
RewriteRule ^folder(.*)$ file.php?id=$1
use these i am not tested but it will be work.

Resources