I just copied a concrete5 project over to my local box and am trying to get it running on localhost. I had permissions problems at the start so I just ran a sudo chmod 777 -R site which remedied that. I then had problems with clicking a link. Anything besides index.php would result in a 404. So I messed around with the htaccess file. It came in this state:
# Use PHP53 as default
AddHandler application/x-httpd-php53 .php
<IfModule mod_suphp.c>
suPHP_ConfigPath /opt/php53/lib
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule . index.php [L]
</IfModule>
and I changed it to this:
# Use PHP53 as default
AddHandler application/x-httpd-php53 .php
<IfModule mod_suphp.c>
suPHP_ConfigPath /opt/php53/lib
</IfModule>
<Directory>
AllowOverride All
</Directory>
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule . index.php [L]
</IfModule>
Now, none of that helped. I decided to just disable pretty URLs in the database. I did that and most links work. It looks like some still don't (maybe the ones that are involved in a package. I don't know because I am picking up this project where someone left it). Bear in mind this all works perfectly on the live server at this time with the first .htaccess file I showed.
Any idea as to how to remedy this?
It does sound like you are having an issue with Pretty URLs. The ones that are still not working after you disabled it are likely do cached items like blocks. If you clear you cache your site will likely work without Pretty URLs turned on.
As for why Pretty URLs are not working, I would first make sure that mod_rewrite is enabled. Then you can try a couple of these for the rewrite rule.
RewriteRule ^(.*)$ index.php [L]
RewriteRule .* index.php [L]
Note: you can use the scripts from your admin login to update "pretty URLs". One caution would be is that if you use .htaccess for another purpose on your site.
Try removing the htaccess completely. Rather than deleting it, rename it. Then get into the dashboard directly at /index/dashboard/ , disable pretty urls, disable and clear the cache, and clear your browser cache.
(In general, always disable pretty urls and disable and clear the cache before cloning a site.)
Once everything is working without pretty urls, you can then start re-enabling.
I've just hit this one whilst trying out concrete5 on my home machine (linux/apache).
In my case, the problem appears to have been because I'd installed concrete5 two directory levels beneath the document root (/var/www/html). Initially, I just created the .htaccess file based on the values given when I enabled pretty urls, then hit the "page not found" problem (couldn't even log in.) Eventually, the penny dropped: I edited .htaccess and changed RewriteRule to point to the actual location of the concrete5 index.php relative to /var/www/html.
So in my case, concrete5 is installed into /var/www/html/playpen/public_html - so the new RewriteRule reads:
RewriteRule . playpen/public_html/index.php
and that appears to work.
Hope it helps someone ...
Related
I started using wordpress with my website (through 000webhost) and then I realized that's not really what I want. Not at all. So I went through and deleted all the files. There was a .htaccess file (for Wordpress) and one called .htaccess_origional. I accidentally deleted the original one and now I'm stuck with a Wordpress one that won't work. It was a file with no restrictions or modifications. I remember that it only had one line. Does anybody know how to get it back? Thanks in advance!
You just have to visit Settings > Permalink and save. It will re-generate the .htaccess file.
If you want to create the initial .htaccess file configuration. Here is the initial .htaccess configuraiton
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Reference: https://www.hostinger.com/tutorials/create-default-wordpress-htaccess-file
It's been a while since I last used their service but if I recall correctly you can rebuild your webdir (or whatever it's called).
You'll have to search for this function in your control panel.
When you click this it will reset your server so BE SURE TO HAVE A BACKUP.
I currently have a problem with rewriting my URL's using the .htaccess file when a Laravel project is in a subdirectory.
usually when not in subdirectory having /vacancies -> /index.php/vacancies using this below .htcaccess file works.
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine on
RewriteLog "/var/log/httpd/rewrite.log"
RewriteLogLevel 3
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
Though now the project exists within a subdirectory I require the URL to be re written as so /vacancies -> /abc/index.php/vacancies.
The home page works correctly though any links just return a not found error.
What changes would I need to have the .htaccess file do this for me.
so on investigating further upon entering 'index.php' into the url itself the page loads correctly if this helps anymore with answering the question.
Thanks!
I wouldn't modify the default .htaccess provided in a Laravel app. You need to use Apache's directory alias in the virtual host config file for your site. You need to have the following format:
#Change the paths accordingly
Alias /vacancies /path/to/app/public
<Directory /path/to/app/public>
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted #If using Apache 2.4 add this.
</Directory>
I managed to fix this thank you for your suggestions, This turned out to be a problem with the virtual host file and where the project was created as I have soft links let up to direct apache.
As such Apache was looking in the actual project location set in the virtual hosts file rather than the soft link one intended causing the not found issues.
Check of .ht* permissions in the apache httpd config file if you are using apache. I had the same problem and I had permissions denied problem for .htaccess file. If you are on shared host, try to contact hosting support.
Tried putting it on top of the htaccess file ? Helps for me in some kind of cases, seems weird but it does.
I notice fro your answer you've managed to "fix" this. However, you have some fundamental errors in the .htaccess file you posted, so I'm not sure how this is working exactly?
RewriteLog "/var/log/httpd/rewrite.log"
RewriteLogLevel 3
These two directives are not valid in .htaccess files and consequently will result in a 500 Internal Server Error. These can only be used directly in the server config or virtual host context. These are also Apache 2.2 directives, so won't work on Apache 2.4.
RewriteRule ^index.php [L]
(Part of the "front-controller"). You are missing a space between the first and second arguments, so this will fail to rewrite any requests to index.php - your "front-controller". (Maybe this is just a typo, but it's difficult to see a typo like this could creep in?) For example, this should be more like:
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
These directives should be before the front-controller, not at the end of the file. Otherwise, they are not going to execute for any request that is routed through your framework.
when not in subdirectory having /vacancies -> /index.php/vacancies using this below .htcaccess file works
That's not actually what the above .htaccess code does. It should simply be rewriting the request to /index.php. (The frawework/Laravel then looks at the full URL that was requested.) If it rewrote the URL to /index.php/vacancies (that some frameworks do) then you would need to read the URL using pathname information (PATH_INFO).
Though now the project exists within a subdirectory I require the URL to be re written as so /vacancies -> /abc/index.php/vacancies.
See above regarding the PATH_INFO. But if the .htaccess file is located in the document root of the site and the /abc subdirectory should be entirely hidden then you still have some work to do. You'll need to set the appropriate RewriteBase and modify the condition that removes the trailing slash off non-directories.
Otherwise, if the /abc directory is part of the URL then the .htaccess file can be moved to the /abc subdirectory, but you'll still need to modify the directives that remove the trailing slash.
My wordpress site lies in a folder called /entwurf/cob1 and since I wanted it to be shown by simply typing in www.cob1.org I changed the permalink to cob1.org and now nothing works. I tried changing the htacces to:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /entwurf/cob1/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /entwurf/cob1/index.php [L]
</IfModule>
but this doesnt seem to work either. I want my files who lie in the entwurf/cob1/ folder to be shown when typing in the cob1.org website.
Currently nothing is seen.
Delete .htaccess, log into your wordpress, and let wordpress to generate .htaccess for you. ( Options -> Permanent Links -> Save)
Check is it working? No?
Upload to your web site root phpinfo file (php file with a content of "<?php phpinfo() ?>"), run it via browser.
Check what Server API cell says -> Apache? If yes Check is there mod_rewrite enabled? No? Ask Support to enable it.
If its not a Apache, ask for a help of the person who setup your server.
If you have access to the Worpdress admin panel go to
Setting > General
and make sure the Wordpress URL and Site URL are correct. They should be your new address. Change those and save it if you want to rewrite all the old URLS in the database.
If you don't have access to the WP admin panel try using this to manually make the changes to your database.
https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
Delete .htaccess and regenerate it. Else use the following:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /entwurf/cob1/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
Secondly, what you are trying to achieve has to be done in two steps.
1) In Settings > General, change the wordpress url in both fields to www.cob1.org
2) In your apache config, set www.cob1.org to point to /entwurf/cob1/
<VirtualHost *:80>
DocumentRoot "complete-absolute-path-to/entwurf/cob1/"
ServerName cob1.org
ServerAlias www.cob1.org
</VirtualHost>
3) Verify that .htaccess is being read. This takes a little bit of experimentation. Eg. I'd place some random text in .htaccess to force a server error on purpose. If I see the error, that means that the .htaccess file is being read. If it's not being read, make sure "AllowOverride All" is set in the apache config. .htaccess files are only read by apache (and apache family servers.)
Restart apache. You're done.
Have been around the houses with this - have read many htaccess issues etc - and still can't seem to get this to work.
I have a WordPress site installed at var/www
I wanted to have a specific URL point to a specific page. Started by browsing some WordPress plugins. None of them worked so I just went straight to the source and started editing the .htaccess file in the root of the WordPress installation. This is where it started getting frustrating.
One of the many attempts at an .htaccess file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
Options +FollowSymLinks
Redirect 301 /redirect-me http://my-wordpress-site/?page_id=15
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
All attempts at a Redirect have resulted in 404 Not Found errors.
I have asserted the following things:
Apache2 Rewrite Module is enabled
www-data has both read and write access to the .htaccess file.
AllowOverride is set to All in the apache2.conf file for the directory
Here's a big clue for you: swapping the last ReWrite rule within my .htaccess file does absolutely nothing to my WordPress site...
RewriteRule . /poo.php [L]
Any other suggestions for debugging a failing .htaccess file?
When you make configuration changes such as AllowOverride in the config, make sure your do a restart on Apache2 so the changes become effective. Give that a shot.
I have a webapp written in Laravel that needs to run in a folder on a web host.
The app will have to be accessible via hostname.com/webhit/. This will point to the app's home page.
I only have one route:
Route::controller('/', 'HomeController');
HomeController's getIndex needs to serve the home page. This works.
However, as soon as I want to go to something like hostname.com/webhit/login, I get a 404 from Apache.
Obviously, .htaccess is not working properly. I need it to, essentially, turn URLs that look like hostname.com/webhit/login into hostname.com/webhit/index.php/login.
I have a .htaccess file in www/webhit (where index.php is located) that looks like this:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ webhit/index.php/$1 [L]
</IfModule>
I am not very familiar with .htaccess file syntax, but I believe it's doing something wrong.
Edit:
I did it. My .htaccess was wrong (it actually causes a redirect loop), but the issue was that it wasn't even being parsed by Apache (hence the 404 instead of a 500 due to >10 redirects in a request). I did the following steps in order to get everything to work:
Enable mod_rewrite and restart Apache (plenty of docs out there on how to do this)
But wait, there's more! By default, Apache on Ubuntu prevents URL rewrites. See this site. Most importantly, the following fragment from the URL above is very important: "By default, Ubuntu's Apache will ignore the directives in your .htaccess files." You will need to actually enable rewrites by editing \etc\apache2\sites-available\default and setting AllowOverride to all (see link above for more details).
Reload the configuration (or just restart apache).
Make sure you're using the correct .htaccess. My original version actually has a redirect loop in it. See the selected response for the correct version.
After this, I got it to work. I hope it helps future programmers having a similar issue!
Check default server requirements - laravel .htaccess file works for most situations. Try with this:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I would suggest you to use resourceful controllers - mappings from your route to your controllers methods are much more clear, and you'll get full
resource with one command (routes,models,views,controllers)