How to shorten a url in .htaccess file - wordpress

I have a wordpress website with the integration of a laravel5.1 app. I use a couple views from the laravel app. How can I shorten the the following url
http://wordpressapp.com/laravel-app/public/item/view/18
I would like to remove /larave-app/public/ from the url so that when they click on the link the url shows as
http://wordpressapp.com/item/view/18
I am not sure if I need to update the .htaccess file in the laravel-app/public folder or the .htaccess file in wordpress or in both files. Thanks

I'm not an .htaccess expert but I know this trick has worked for me in the past:
RewriteRule ^laravel-app/public/(.*)$ /$1 [L,NC,R]
I imagine that the .htaccess file in the root of the site (WP) would need to be edited for this. I'm not sure what impact the "L" in the rule will have on the laravel app, perhaps it's worth giving it a try and testing?
This site: https://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/ has some interesting explanations for you if you need more customisation.

Related

Silverstripe install root folder public

I have installed silverstripe 4 into the /var/www/html folder in apache.
However, when I go to the url, I have to use "localhost/public/index.php" in order to obtain the main page. I thought I was to be able to just go to "localhost" to find the defaut page. What am I to do if I want to have a main page without people having to specify "/public/" before it?
Thanks.
Normally, your localhost website can be resolved without adding /public/ if the following 2 things are configured correctly.
Enable Apache mod_rewrite
Having .htaccess rewrite config in /var/www/html
Troubleshooting
Check if you got the right .htaccess in /var/www/html. Basically, this Apache config file will forward all the requests to /public/ folder.
If .htaccess is fine, make sure your mod_rewrite is enabled in your Apache. Check this link.

Wordpress Apache2 mod_speling not working

I am in the process of migrating my site to Wordpress from IIS.
I have run into an issue:
I have URL's that are a mix of upper and lower case that reference images. These URL's are getting a 404 because the case of the URL does not match the case of the file location.
For example, in my article I have a URL:
https://aaa.bbb.com/wp-content/migrate/ABC/abc.png
The file this is referencing is: /var/www/aaa/wp-content/migrate/abc/abc.png
When I change the URL to the same case as the file, it works, however how can I make it ignore the case of the folder on disk?
I tired the mod_speling module by putting this into /etc/apache2/apache2.conf but this just does not work for me. Also tried putting this into .htaccess in the root of my web directory but that made no difference.
<IfModule mod_speling.c>
CheckSpelling On
CheckCaseOnly On
</IfModule>
I have read various threads on here but I'm completely stuck.
I managed to find a work around to this.
I ended up writing a rewrite rule in the VirtualHost file to rewrite everything to lowercase apart from anything within the directory of assets imported from Windows.

Symfony directory structure on cPanel site

I'm building my first Symfony site that will eventually be hosted on a shared server/cPanel site.
I'd like to have my Symfony/web content separate from the server files, though the way Symfony is structured, all the Symfony files are outside the public_html folder. But with a cPanel setup, there's already a lot of files and folders outside the public_html folder (mail, logs, .bashrc, .cpanel, www alias... and a dozen others).
I worry that it feels messy if I put Symfony mixed in with all these files and there could be a conflict. I would rather it be in a directory by itself. The best idea I've had so far is to make a subdomain to host Symfony where I can manually choose the web folder, and then just do redirects to the subdomain.
What do others do?
This is how I decided to do it, and it seems like it will work pretty well. I just use the regular cPanel public_html as the document root, upload the whole Symfony contents to that directory, but then add an .htaccess file with the contents:
RewriteEngine on
RewriteCond %{REQUEST_URI} !web/
RewriteRule (.*) /web/$1 [L]
And that protects the main Symfony contents from public access while at the same time putting it all in a directory by itself. It seems to work so far. If anyone has a better idea, I'm open to it!

Allow .htaccess edition

I'm trying to make my wordpress site more secure, so I need to add some rules on my .htaccess. But suddenly, I made the following mistake:
RewriteRule ^(php\.ini|\.htaccess) - [NC,F]
And now I can't write more rules in it. Everytime I try to edit, I get the message:
Error: Forbidden file edition: //httpdocs/.htaccess: filemng: Error
occurred during /bin/cp command.
I already tried to:
Delete the file and create again
Replace the code
Upload from my computer...
Replace via SSH
All in vain.
When I used SSH, the old code (standard htaccess generated by wordpress) was there, but somehow the rule is still applied on the file. I can't edit it.
What can I do?
Thanks & sorry for my bad English.
Try to connect to your webserver with filezilla or something else.
Here an example of the basic .htaccess: Wordpress .htaccess

Create folder in symfony root that is not controlled by symfony

I want to create http://localhost/Symfony/temp/.
In temp will be a basic index.html and some images. If I create the folder right now and put the index.html file in /temp/ I get a 404.
How do I get a normal response from http://localhost/Symfony/temp/index.html?
Requests going to temp/ are being caught by Symfony's default .htaccess. You'll have to add following:
# allow access to temp
RewriteRule ^temp.* - [QSA,L]
If you want it to work even with app_dev.php just change it to ^[app_dev.php/]*temp.*.
But I'm more interested why do you want to do that in root directory and not in static files directory (eg. web/static/temp). You wouldn't need to mess around with .htaccess and you'd be able to link to such images with asset(...).
Here's the solution I eventually came up with.
All I did was create a .htaccess file in /temp/ and inserted:
allow from all
Since I was getting a 404 error and all the other symfony folders had a .htaccess with
deny from all
I reversed engineered an answer.
Hope this helps someone else.

Resources