Mapping host name Zend2 - php

I have developed a site recently which home page opens when i hit this url but i want to open my site home page when user hit only this link.

update your apache vhost configuration and set the DocumentRoot to ght/public/

If you only have access to the data directory, but not to the apache config itself, you can add a .htaccess with contents (must be allowed by the server):
RedirectMatch 301 /(.*) /ght/public$1
Alternatively, why don't you upload your PHP and HTML files directly into the webserver root? (above the /ght/public/ directory) What access to you have to the webserver?

Related

Webiste url are not routing without index.php

I uploaded my website from my UAT/Test domain to EC2 AWS. Before everything was fine, but now only home page opens.
And if I try to navigate to any other links I can't, it gives following error
The requested URL /page/company was not found on this server.
But when I insert index.php in between it works fine.
Any ideas?
Please enable mod_rewrite module in your server and rewrite index.php in htaccess file.
Please check your file premissions
I believe the issue could be DirectoryIndex which apache (not positive that is what you are using as web server) uses to direct the user to a specific file if a directory is selected in the URL.
This can be set in your apache config if you have access, or in a .htaccess file if you only have access to the your webspace itself.
http://www.htaccess-guide.com/directoryindex-uses/
Basically with DirectoryIndex you can tell apache to automatically use index.php, or index.html, or really whatever file you want to be used when no file in a directory is given in the URL.

mod rewrite and htaccess with subfolders

I had a site set up on one server, and it has subsequently been moved.
I had a subdomain that processed a link and forwarded it on. However, with the server move the files now sit in a different place!? Let me explain
SERVER A
example.com (run main site)
my.example.com
I was able to create a subdomain and run files in it with no problem. The main domain and subdomain run like separate sites. My .htaccess file on that worked and had the following lines of code:
RewriteEngine On
RewriteRule ^([0-9a-zA-Z]*)$ index.php?profileId=$1
SERVER B
example.com (run main site)
my.example.com (the files now sit in a subfolder in the root of my main domain so example.com/my.example.com.)
This affects my .htaccess file now and although the subdomain is set up. When I run the page I get a "no input file specified error".
How do I resolve this? Its just a simple file to process but my issue is I have 10000 pre printed QR files that I am unable to change so need to resolve my issue.
RewriteEngine On
RewriteRule ^([0-9a-zA-Z]*)$ index.php?profileId=$1
This should still work OK, assuming...
this .htaccess file is now in the document root of your subdomain (assumed to be example.com/my.example.com) and not the main domain's document root.
The index.php file (referenced in this directive) is located at my.example.com/index.php (not example.com/index.php).
Also, make sure that MultiViews is disabled. You might need to add the following to the top of your .htaccess file:
Options -MultiViews

how to counter dot dot slash attack?

How can I restrict the user into the root directory and not able to get access to the parent directory of the root.
I have EasyPHP installed and following I am considering as root:
http://127.0.0.1/projects/Web%20Developement/aureus/files/
I don't want user to able to move to the parent directory but when I add "dot dot slash" ../ at the end of above URL I can access "aureus" directory. How can I stop this by .htaccess or any other way?
You can't do correctly with .htaccess. You'll need to edit the configuration for the domain in the main config file. When you go into your httpd.conf file or your included file for the virtual hosts you need to look for the DocumentRoot you're setting for the server. The web server only has access to what you grant it.
If you can access a folder you're trying to lock down via the web or a browser on another machine, you'll need to look at a variety of permissions settings depending on the OS you're running. You can restrict access to folders and prevent the users in Linux for example from seeing the files with chmod. In Windows (if that's what you're running) you would right-click on the folder, select properties, and change the permissions under the security tab.
Not sure what the point of all this is, but if you simply don't want any ../ in your URLs, then you can try adding this to your htaccess file:
RewriteEngine On
RewriteRule ^(.*)\.\./(.*)$ /$1$2 [L,R=301]
I think rather than specifically try to stop the use of ../ in the url, you should have htaccess in folders you do not want people/bots/other to be in.
This
Options -Indexes
in a .htaccess file will stop directory listing in whatever folder the htaccess file is in. It'll serve a 403, but you can use htaccess to serve 404 or redirect based on what you need (other than "stop user to able to move to the parent directory" I'm not 100% sure what you want)
Cheers

how to move a apache localhost website to internet (i.e remote server)

i have few conceptual queries about moving a locahost site to server for making it available on internet.....what are the steps...how server will recognize the changes in my apache and php config files..i have built a website in php and mysql on apache 2.2
NOTES:
i have made some changes in my apache config files.one of them is i
have included a fillename "index.php" in
"DirectoryIndex"...so now my DirectoryIndex looks like:
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
so now automatically my apache tells the browser to search for a index.php file whenever header('LOCATION:') or refresh is called.and it's obvious that my index.php files holdas the html and and other php codes which will be shown or displayed
third and most importantly...i have used header function in many cases while building the website..my header functions are like header('Location: http://localhost/home/');
so repeating the question again
should i change all the header functions while uploading acording to my website name
i.e
header('Location: http://www.my_site_name.com/home/'); in place of
header('Location: http://localhost/home/');
and who will my remote server will recognize the changes i have made in my config file and will work according to the changes
and what are the steps to upload a website to internet
and who will my remote server will recognize the changes i have made
in my config file and will work according to the changes
Normally hosting servers are configured to allow the use of .htaccess files to override apache configuration
you may create a .htaccess file in your root directory and place there your DirectoryIndex settings
should i change all the header functions while uploading acording to
my website name i.e header('Location: http://www.my_site_name.com/home/');
in place of header('Location: http://localhost/home/');
Why not using relative paths or simply:
header('Location: /home/');
and who will my remote server will recognize the changes i have made
in my config file and will work according to the changes
That way, it'll work on both servers.
and what are the steps to upload a website to internet
You should use a FTP client to upload your website to your webhost.

how to hide files in the www directory

Is it possible to hide a folder from the www directory so that the php files will not be seen if you access it through a web browser?
I'm doing this because I'm not yet good enough to secure those files and the mysql database that they are manipulating.
Or even a trick that would make the web browser not to be able to access the localhost is fine. Please
If you have a directory and you don't want Apache being able to serve any file that's in it, you can create a .htaccess file in that directory, containing :
Deny from all
This will make sure Apache refuses serving any file from that directory -- but they will still be accessible by PHP scripts running from another directory or from the command-line.
If you want Apache to be able to serve the files, but not list the content of the directory when a user accesses that directory without any filename in the URL, you can use this in your .htaccess file :
Options -Indexes
This will disable listing of files inside the directory that contains the .htaccess file -- but will not prevent Apache from serving the files themselves.
Just put the files outside of the document root and include them from there.
A very simple trick if you don't have Apache, hence no access to .htaccess (that sounds like I'm repeating myself), just create a file index.htm or index.html containing NOTHING. Any attempt to access that folder will just show a blank page.

Categories