How do I move up a directory using the &lt;link&gt; in HTML for my stylesheets to work while using htaccess? My directories are as: index.php .htaccess css/     styles.css php/    login.php  In my htaccess, it contains: RewriteRule ^login/?$ php/login.php [L,QSA,NC]  Now, the stylesheets work when I copy the css folder to inside my php. They work with href=&quot;css/styles.css&quot;. I don't want that. I want to move up and out of the php directory to the css folder in my root directory. But the stylesheets won't show when the href=&quot;../css/styles.css&quot;. How do I move up a directory to use my stylesheet in the root css folder with htaccess? EDIT: I have tried using the &lt;base href=&quot;/&quot; /&gt;, but that prevents the stylesheets from loading on both /login/ and /login.php. login.php: &lt;script src=&quot;https://code.jquery.com/jquery-3.1.1.min.js&quot;&gt;&lt;/script&gt; &lt;script src=&quot;../js/system.js&quot;&gt;&lt;/script&gt; &lt;link href=&quot;../css/styles.css&quot; rel=&quot;stylesheet&quot; /&gt;  .htaccess: ErrorDocument 404 http://localhost/Sites/OrderFresh/html/error404.html RewriteEngine On RewriteRule ^login/?$ php/userconnect.php [L,QSA,NC] &lt;Files .htaccess&gt; order allow,deny deny from all &lt;/Files&gt;
88295
I am trying to make my url from this:  example.com/view.php?id=15   To this:  example.com/watch/15   My code in .htaccess is as follows:  Options -Indexes Options +FollowSymlinks RewriteEngine On RewriteRule ^watch/([^/]+) view.php?id=$1 [NC]   Now if I go to example.com/watch/15 it loads the content but without any JS, CSS because in this case it looks for CSS and JS under the /watch folder which doesn't exist.  How do I make this option work properly? I don't want to create watch folder and copy-paste CSS and JS so it will embed properly.
99359
I'm coding a small CMS to get a better understanding of how they work and to learn some new things about PHP. I have however come across a problem.  I want to use mod_rewrite (though if someone has a better solution I'm up for trying it) to produce nice clean URLs, so site.com/index.php?page=2 can instead be site.com/tools  By my understanding I need to alter my .htaccess file each time I add a new page and this is where I strike a problem, my PHP keeps telling me that I can't update it because it hasn't the permissions. A quick bit of chmod reveals that even with 777 permissions it can't do it, am I missing something?  My source for mod_rewrite instructions is currently  incase it is important/useful.
69879
I need to (permanent) redirect all of the following:   www.example.com www.example.com/folder sub.example.com sub.example.com/folder   Basically, all URLs that are reachable without being intended to: www.new-example.com, I want to do this within Apache and using the mod_rewrite module via the .htaccess file.
7008
I'm working for a website to convert the website URL to an SEO friendly URL. I plan to use this:  example.com/category-name/pageid-123-page-name  I looked at some similarly categorized, highly ranked websites. They have the same structure, except for one thing. In one case, the URL format was  example.com/category-name/pageid-123-page-name.html  Another was   example.com/category-name/pageid-123-page-name.php  Now I know the text in URLs help with SEO. Is it more helpful to have a file extension? If yes, which one is better?  Or if my current plan is okay, will it be better with a / at the end?
107224
Im having issues as to which user should own my www directory - ftp or apache? When set to the ftp user, the user can add, remoe and easily modify files but php file system actions generate permission denied errors (ofcourse because they require the user to be apache). If however, the www directory is chown to apache, the ftpuser wont be able to perform some actions like file modification and deletion. Any one ever encountered similar issue? What's the fix? Thanks
114897
How do I actually run a file on localhost? I know it is working, but how do I run a file on it, and how do I verify that the file is in fact running on localhost?  Server newbie here, additional questions (I have xampp running Apache 2.2): From your responses it sounds like I have to type in the path in the browser in order to open the file on the localhost. So, if I want to have the file in a subdirectory, I would have to type the full path including the directory?   Is there a way to have the browser point to the localhost while I am working on my html, instead of having to type in the path all the time?  I am working in Dreamweaver CS3, and want to use include commands (either SSI or PHP), but not have to keep putting my files up on HostGator in order to see if they are working.  What is the best way to do this (please be specific, I know nothing). If there is a detailed tutorial anywhere, really appreciate a link.  Thank you
122141
I having a weird problem on my VPS with Ubuntu 14.04 as the server. I tried creating a directory with php mkdir using the code below  &lt;?php      mkdir("/items/foldername", 0777, true); ?&gt;   Whenever i run this script,the folder gets created but with 755 permission instead of 777.  I have tried all available options I can see none is working. My php script is using www-data.   I have tried the following   sudo chmod -R 777 items  sudo chmod -R g+s items I added www-data to the root group
76790
I've looked at dozens of other questions and references on the web - and by all my calculations, my setup should work, but it doesn't.  I have nginx installation with php-fpm.  If I try to access a .php file, it runs correctly and I get the correct results.  I got this in my config file:  location ~ \.php$ {     try_files $uri =404;     fastcgi_pass unix:/var/run/php5-fpm.sock;     include fastcgi_params;     fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name; }   Now, I want to setup my web app so that /somedir/file automatically executes /somdir/file.php while still displaying /somdir/file in the browser's address bar.  So I modified my config to contain the following:  location / {     try_files $uri $uri/ $uri.php?query_string }   This kind of works, that is, the server does access the .php file.  Yet, instead of executing it using the existing location ~ \.php$ block above, it simply spits the php source code as the download into the browser.  If I append the .php manually to the requested URL, then the php is executed.  It feels as if once the server matches try_files to $uri.php, it then does not do another pass at locations to see that what it needs to do with the php files.  I tried putting the php block above and below the location /, but it makes no difference.  How can I get the php to be executed?
13585
This is a  about File Permissions on a Linux web server.   I have a Linux web server running Apache2 that hosts several websites. Each website has its own folder in /var/www/.  /var/www/contoso.com/ /var/www/contoso.net/ /var/www/fabrikam.com/   The base directory /var/www/ is owned by root:root. Apache is running as www-data:www-data. The Fabrikam website is maintained by two developers, Alice and Bob. Both Contoso websites are maintained by one developer, Eve. All websites allow users to upload images. If a website is compromised, the impact should be as limited as possible.  I want to know the best way to set up permissions so that Apache can serve the content, the website is secure from attacks, and the developers can still make changes. One of the websites is structured like this:  /var/www/fabrikam.com     /cache     /modules     /styles     /uploads     /index.php   How should the permissions be set on these directories and files? I read somewhere that you should never use 777 permissions on a website, but I don't understand what problems that could cause. During busy periods, the website automatically caches some pages and stores the results in the cache folder. All of the content submitted by website visitors is saved to the uploads folder.
49597
This is a double question: The correct answer will go to "How you do it in PHP" explaining if there is any advantage goes also counts if possible.  I'm just curious because I really don't know and I see it a lot in webpages.  Edit: I don't know the technical name, but for example here on Stackoverflow: "http://stackoverflow.com/posts/edit/522452" is what I mean as "folders" (a term previously used in the title of the question).
102040
I have the following virtual host setup:  RailsBaseURI /  &lt;VirtualHost *:80&gt;     ServerName mydomain     DocumentRoot /usr/share/redmine/public      Alias /evaluation /home/user/evaluation/      DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm      &lt;Directory /usr/share/redmine/&gt;         Options +FollowSymLinks Indexes         AllowOverride All         Order allow,deny         Allow from all     &lt;/Directory&gt;      &lt;Directory /home/user/evaluation/&gt;         Options +FollowSymLinks Indexes         AllowOverride All         Order allow,deny         Allow from all     &lt;/Directory&gt; &lt;/VirtualHost&gt;   When I go to mydomain/evaluation, I get an error. But when I go to mydomain/evaluation/index.php, it works. What am I doing wrong here?  Update: I have confirmed that the request is routed to Redmine instead of being handled by Apache. Any ideas?
45679
I have a site directory for html (dreamweaver CSS3) with lots of subdirectories that contain HTML files for a number of drop down menus. They work fine where they are, but they all have menus that are JavaScript and could be kept in a separate file. So, I want to use Include. I don't want to have to FTP my files to HostGator every time I want to test the includes. I want to have this on my local machine. So, I am attempting for the first time to setup XAMMP and then run my html files (site) on localhost, so I can see what they look like before ftping everything to HostGator and putting it live.  I tried copying the main site folder to htdocs, and then copying the path to the file I want to run in front of the localhost in Firefox, but it gave me file not found:   Do I have too many subdirectories? Why isn't the file being found? It is there.  Tried this too:   No go.
46436
I am writing a small website, but I do NOT want to figure out how to install and configure complete LAMP stack to test the website from my ~/home directory. That will be completely disruptive and unnecessary.  All I want is to have a directory, e.g. ~/home/Documents/Website and run a small web server from that folder as the website's "home" folder.  I know  can do something similar, but it only seems to work with Ruby/Jekyll-based sites that it builds and configures.  Isn't there some small web server program that I can easily install and then just run very simply?  For instance, if I just needed to run something like e.g. simple-server serve ~/home/Documents/Website from a command line and then navigate to e.g. localhost:4000 or whatever to test the site, that would be perfect.  If this is already possible in Ubuntu and I just don't know how, please let me know.
92050
I have a mirror of a large website that I need to reorganize, most of the images and files I've been able to programmatically move and relink up; however, there are a few (few is a relative term, we're talking 3,000 odd files) I need to locate within the mess of folders.  I know the filename(s) (I have big long lists and I'm assuming they're unique, or at least unique enough that I can fix any collision manually) but not their location within the file structure, and I need to copy them to a separate directory so that I can then upload them.  In short, I have a list like  file1.jpg file2.doc file4.ppt filesomethingelse.this   in a file (say, filelist.txt).  And I have a folder structure like  folder\subfolder\file1.jpg folder\subfolder\file2.doc folder\subfolder2\filesomethingelse.this folder\file3.jpg folder\file4.ppt   and I want to get  secondFolder\file1.jpg  secondFolder\file2.doc secondFolder\file4.ppt  secondFolder\filesomethingelse.this   Note that file3.jpg should not be copied because it is not on the list.  Something command line like (xcopy or robocopy) would be the best option I guess, so I can batch up the requests.  Hope this makes sense.
64625
I'm trying to not give 777 permission in my /var/www/html folder, but I want to edit my files without sudo. So I though in create a symlink of a folder in my home directory within /var/www/html. I created it using sudo ln -sT /home/andre/www/moodle/ moodle , and the ls -la output is this:  andre@andre-270E5G:/var/www/html$ ls -la total 8 drwxr-xr-x 2 root root 4096 Mai  4 10:20 . drwxr-xr-x 4 root root 4096 Abr 29 14:29 .. lrwxrwxrwx 1 root root   23 Mai  4 10:20 moodle -&gt; /home/andre/www/moodle/   So, my moodle folder has read, write and execute permissions for everyone, and thats not what I want. I used the command sudo chmod -R 775 moodle/ trying to change it, but it stayed with read, write and execute permissions to all. I tried the same with the moodle folder in /home/andre/www/moodle, but it stayed the same. The output of ls -la in /home/andre/www/ is:  andre@andre-270E5G:~/www$ ls -la total 28 drwxrwxr-x  3 andre andre  4096 Mai  4 10:02 . drwx------ 49 andre andre 20480 Mai  4 10:01 .. drwxrwxr-x 41 andre andre  4096 Mai  4 10:02 moodle   So the folder moodle in /home/andre/www/ has the permissions I want.  As an additional problem, when I access localhost/moodle I get 403 Forbidden error.  What am I doing wrong here?
78463
Does anyone know if there is an equivalent to .htaccess and .htpassword for IIS ? I am being asked to migrate an app to IIS that uses .htaccess to control access to sets of files in various URLs based on the contents of .htaccess files.   I did a google search and didn't turn up anything conclusive. Is there a general approach or tool that I need to purchase that provides this capability ?
84513
I use a cookieless sub domain static.example.com to serve all images, js, and css files. This static sub domain has as its root directory the same directory as the parent http://example.com. So static.example.com/index.php will result in calling the same file as http://example.com/index.php  Google has taken up indexing static.example.com and I need to stop this.  I can't modify robots.txt since it would apply to both domains. Webmaster tools allows "temporary" removal of a link, but this needs to be permanent.  I registered this static domain through google as a separate site from example.com, but this doesn't seem to buy me anything since I can't see a way to block crawling without using robots.txt - which would block it from the parent domain.  Any other ideas?  UPDATE  Found this conversation on   I am looking into whether it's possible to insert a META tag dynamically into the header of every page called on the static domain using php  CLARIFICATION  I am not putting any content on static.domain.com. There are NO webpages on it that are called - it only serves images. I have it redirecting to the same root directory as the main site for ease of coding image links (not every image is fed from the same image path).  Google got a hold of the static web root address - probably because .htaccess redirects to index.php if a file is missing and then crawled it. Now Google is showing the static version of the same pages with search results.